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

Tell something about the super block in shell scripting?

0 Answers  


Can we run shell script in windows?

0 Answers  


How to take input values from the user?

4 Answers  


How will you emulate wc –l using awk?

0 Answers  


is there any command to find user password?

4 Answers  






What is the significance of the shebang line in shell scripting?

0 Answers  


How to print pid of the current shell?

0 Answers  


In a file , how to retrieve the lines which are the multiples of 50 ? like 50,100,150th lines etc.

9 Answers   Amazon,


Print a given number, in reverse order using a shell script such that the input is provided using command line argument only.

0 Answers  


write a shell script that counts a number of unique word contained in the file and print them in alphabetical order line by line?

6 Answers   IBM, Wipro,


What is the default shell of solaris?

0 Answers  


What is the difference between a shell variable that is exported and the one that is not exported?

6 Answers  


Categories