LINUX programming

Moderators: ITA
Number of threads: 1339
Number of posts: 2924

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
heeeeeeeeeeeeeeeelp Posted by gorilka on 4 Apr 2004 at 12:15 PM
Please explain to me this : (PLEASE!)

The following script written in file q4 has been started with the command:
sh q4 test


#!/bin/bash

awk '
{
if (data[$0]++ == 0)
lines[++count] = $0
}
END {
for (i = 1; i <= count; i++)
print lines[i]
print "'$1'", count > "fs"

} ' $1

i=`cat $1 | wc -l`
set `cat fs`
&#61662; echo "The number of . . . . . . . . . . in " $1" is " $2

&#61662; echo "The number of . . . . . . . . . . in " $1" is " $i

&#61662; echo -n "The number of . . . . . . . . . . in " $1" is "

expr $i - $2




The input file is called test:1. First line
2. Second line
3. Second line
4. Second line
5. Third line
6. Second line
7. First line
8. Fourth line
9. Fifth line
10. First line
11. Sixth line
(# of lines is not included)


Answer is:

Insert the missing word(s) in the lines marked by &#61662; (20 points)
lines
the deleted/duplicated lines
the unique lines



Write the exact output of this script: (40 points)

First line
Second line
Third line
Fourth line
Fifth line
Sixth line
The number of lines in test is 11
The number of deleted/duplicated lines in test is 5
The number of the unique lines in test is 6


Please just explain me the script!!! especially the first two lines!!! thanx!!!









 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.