heeeeeeeeeeeeeeeelp - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

heeeeeeeeeeeeeeeelp

gorilkagorilka Posts: 90Member
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`
 echo "The number of . . . . . . . . . . in " $1" is " $2

 echo "The number of . . . . . . . . . . in " $1" is " $i

 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  (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!!!






Sign In or Register to comment.