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



Create a bash shell script to sort and then uniq the file from the command line & store it to ..

Answer / vipul dalwala

sort $1 | uniq | tee output.txt

Is This Answer Correct ?    5 Yes 0 No

Create a bash shell script to sort and then uniq the file from the command line & store it to ..

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

Create a bash shell script to sort and then uniq the file from the command line & store it to ..

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

Create a bash shell script to sort and then uniq the file from the command line & store it to ..

Answer / supriya

sort -u filename1 |tee file2

Is This Answer Correct ?    0 Yes 0 No

Create a bash shell script to sort and then uniq the file from the command line & store it to ..

Answer / linuxdemon

sort $1 | uniq > output | echo "`cat output`"

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More Shell Script Interview Questions

What is MUTEX?

1 Answers  


How to know that your remote server is ruing smoothly or not in unix?

1 Answers  


What is the command to find out users on the system?

0 Answers  


What is the use of script interpreter in shell scripting?

3 Answers  


What is meant by dos operating system?

0 Answers  






How are shells born?

0 Answers  


why did you apply to shell

3 Answers   Shell,


I want to read all input to the command from file1 direct all output to file2 and error to file 3, how can I achieve this?

1 Answers  


Explain about the slow execution speed of shells?

0 Answers  


Why is a script important?

0 Answers  


In shell scripting if text is surrounded by single quotes what does it denotes?

3 Answers  


Hi, i want to zip the files that generates automatically every few minutes (files generated are in .arc extension)....any body write a script for this... thanks in advance

5 Answers   HP,


Categories