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

What are the different variables present in linux shell?

0 Answers  


What are filters explain sort with all the options available?

0 Answers  


What are the advantages of using shell scripts?

0 Answers  


whta is the use of "exec" command?

1 Answers  


What is an sh file?

0 Answers  






In a single command how do you run the previous command in the command prompt.

5 Answers  


How do you read arguments in a shell program - $1, $2 ..?

4 Answers  


What is meant by $1 in shell script?

0 Answers  


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

0 Answers  


c program which accept one argument as a directory name and prints all the file name along with its inode number and total count of the file in directory

1 Answers  


How to open a read-only file in the shell?

0 Answers  


What is a shell script in windows?

0 Answers  


Categories