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

How can you get the value of pi till a 100 decimal places?

0 Answers  


How to get script name inside a script?

0 Answers  


What does the sh command do?

0 Answers  


What are the zombie processes?

0 Answers  


What is the crontab?

0 Answers  






RAM one table colums a1,a2,a3,a4 respective values 2,4,7,8 KRISH one table colums a1,a2,a3,a4 respective values 3,4,6,9 IN RAM & KRISH a4 column if comparing values RAM A4 - KRISH A4 ( 8-9 =1 THEN print 5 or (RAM) a4 value 10 KRISH a4 values 2 then 10 -2 =8 print 5*8=40 or diff 5 print same

1 Answers   Tech Mahindra,


what does "kill -9" and "kill -1" do

2 Answers   Amazon,


What happens on a system call?

0 Answers  


What is the use of "test" command?

2 Answers  


How to calculate the number of passed arguments?

0 Answers  


write a shell script to check the failed jobs?

0 Answers   Wells Fargo,


Rewrite the command to print the sentence and convert the variable to plural: echo “i like $variable”.

0 Answers  


Categories