Create a bash shell script to sort and then
uniq the file from the command line & store it to a new
file and output the results to the screen. Name this
script "sortAndUniq.sh"
Answers were Sorted based on User's Feedback
Answer / vipul dalwala
$1 is the filename u are passing from commnadline
i.e. sh sortAndUniq.sh filename.txt
So $1 = filename.txt
All the commnadline parameters passed to the script are get
stored in $1 , $2, $3....
For example : sh sortAndUniq.sh filename1.txt filename2.txt
filename3.txt
Then $1 = filename1.txt , $2 = filename2.txt , $3 =
filename3.txt
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / roopa
hey can you please tell me what is the avlue of $1
and how do we specify that in our script?
| Is This Answer Correct ? | 1 Yes | 0 No |
sort $1 | uniq > output | echo "`cat output`"
| Is This Answer Correct ? | 1 Yes | 2 No |
A file has multiple records each having three 30-bit long fields(field1,field2,field3).There is also a lookup file,LOOK_UP.dat.Now, we need to consider only the last ten digits of field1 and lookup the file LOOK_UP.dat. If there a match then field2 and field3 should replaced with corresponding data from the lookup file. otherwise that particular record,for which there is no match, should be stored in a seperate file.
what is the difference between sh & bash shell?
What is bourne shell scripting?
What is the use of .sh file?
Determine the output of the following command: name=shubham && echo ‘my name is $name’.
What is shell terminal?
What is scripting used for?
What is a boot block?
How will you emulate wc –l using awk?
How to find all the files modified in less than 3 days and save the record in a text file?
how to find weblogic version through linux cammand
What are the different types of shell scripting?