raj028
1
Hi there,
I am new to Unix and had below requirement to finish my task.
I have file1.dat which has data as shown below.
case1.txt
case2.txt
case3.txt
case4.txt
file1.dat has only file names
I have folder which has above files mentioned in file1.dat
./all_files
case1.txt
case2.txt
case3.txt
case4.txt
data in case1.txt, case2.txt, case3.txt:
step1
step2
step3
step4
Now, I have to take particular step say step2 from each file, which is also present in file1.dat
Note: step2 is not line no:2 always.
zaxxon
2
Is this homework and if no, what have you tried?
raj028
3
Hi zaxxon,
thanks for your tips on formatting.
I didn't tried as i am new to unix.
I am just familiar with the commands, but not the scripting.
Thanks for understanding.
RudiC
4
Unfortunately, you don't mention the shell you use. With e.g. bash
, try
grep step2 $(<file1.dat)
.
raj028
5
sorry RudiC, forgot to mention yes its bash shell.
file1.dat has only file names.
where as the files(case1.txt, case2.txt, case3.txt) exists in ./all_files folder
lets say file1.dat is also in same folder
ex: the step2 in case1.txt should display if the file name 'case1.txt' is present in file1.dat
Please help
RudiC
6
What's the result of the proposal in post#4 if run in directory all_files
?
raj028
7
the expected result will be..
step2 from all files (case1.txt, case2.txt, case3.txt), because the name(case1.txt, case2.txt, case3.txt) exists in file1.dat