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 to declare functions in unix shell script?

4 Answers  


What is inside a seashell?

0 Answers  


Explain about sourcing commands?

0 Answers  


Why we are writting shell scripts? Plz if possible explain it briefly.

6 Answers   ITC Infotech,


How will you emulate wc –l using awk?

0 Answers  






The information of the two files should be redirect to Third file in such a way that, the third file contain the information like this. 1st line in third file should be from 1st file 2nd line in Third file should be from 2nd file 3rd line in Third file should be from 1st file 4th line in Third file should be from 2nd file - - so on

2 Answers   Caritor,


How to create environment variables?What are the conditions for creating variables?

1 Answers   Infosys, Wipro,


I Forgot My Windows Vista Password! How Can I Find My Windows Lost Password?

1 Answers  


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

0 Answers  


In which variable prompt value is stored?

2 Answers  


How do I open the shell prompt?

0 Answers  


What is a program shell?

0 Answers  


Categories