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 would you replace the n character in a file with some xyz?

7 Answers  


Explain about shebang?

0 Answers  


What is shell variable?

0 Answers  


how will you find the total disk space used by a specific user?

0 Answers  


What is k shell?

0 Answers  


What is shell and shell script?

0 Answers  


How do we create command aliases in a shell?

0 Answers  


What command needs to be used to take the backup?

0 Answers  


Hello all, This is my assignment on shell scripting, can anyone help me regarding this ? Create a shell script which connects to the database In second shell script include the first script for the DB connection Create a table (PRADEEP_DATA) with 2 columns (name, value) In Third shell script include the first script for the DB connection And insert/delete the values from the Table, by accepting input from the user This functionality should be a menu driven Program: 1) Insert to the database a. Name b. value 2)Delete from the database a.Name b.value Exception handling needs to be taken care.

0 Answers   Cap Gemini, Wipro,


How do we delete all blank lines in a file?

0 Answers  


What is meant by $1 in shell script?

0 Answers  


What are the Different types of shells?

5 Answers  


Categories