There is a record with fields namely name,roll
no.,salary,grade etc.Now,write a script to create a file
with multiple records have same combination of fields but
with unique roll numbers.The script should work for
different names in the input file.



There is a record with fields namely name,roll no.,salary,grade etc.Now,write a script to create a..

Answer / sabhapathi

Don't mind my answer is lengthy....
Let file name be employee

name, rollno., salary, grade

cut each of records in each field to temp files as follows:
-----------------------------------------------------------
cut -f1 employee > /sm.tmp.$$
cut -f2 employee > /sn.tmp.$$
cut -f3 employee > /so.tmp.$$
cut -f4 employee > /sp.tmp.$$

Paste them as required in to another file as follows
----------------------------------------------------
paste /sn.tmp.$$ /sm.tmp.$$
paste /sn.tmp.$$ /so.tmp.$$
paste /sn.tmp.$$ /sp.tmp.$$

Is This Answer Correct ?    5 Yes 2 No

Post New Answer

More Shell Script Interview Questions

How will I insert a line "abcdef" at every 100th line of a file?

2 Answers  


How do you create a shortcut in linux?

1 Answers  


How do I run a .sh file on mac?

1 Answers  


What is a shell script in windows?

1 Answers  


What does echo mean in scripting?

1 Answers  


Calculate a real number calculation directly from the terminal and not any shell script.

1 Answers  


I want to upload a file to remote server through ftp daily.Can anyone suggest how to make a shell script for that.I hv credentials for that ftp

1 Answers  


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

2 Answers   Amazon,


Is bash a shell script?

1 Answers  


What is .sh file in mac?

1 Answers  


write a scwipt that a) takes exactly one argument, a directory name. b) if the number of argument is more or less than one,print a usage message c) if the argument is not adirectory, print another message d) for the given directory, print the five biggest files and the five files that were most recently modified. e) save the output to a file called q2output.

2 Answers  


What is the syntax of while loop in shell scripting?

1 Answers  


Categories