I want to concatenate 100 files to one file and append file name in each record to find out which file it came from
for a in $(<shal_group)
do
cat $a >> bigoutput.group
The above code put all files in one file but i want file name appended to each file
Record should be like this
file1| data ...
fiel2| data....
Appreciate your help
for i in $(< shal_group)
do
awk '{print FILENAME, "|", $0 }' $i
done > outputfile
Thanks jim mcnamara it works.
I need a minor change in this.
Record looks like this
/user/tmp/server1_etc_group| data ...
/user/tmp/server2_etc_group| data....
I want data like this
server1|data....
server2|data
Thank you sir
Hi,
Try the below code:
#!/bin/sh
for i in `cat concatinfile`
do
while read line
do
echo "`echo $i | cut -d"/" -f4 | cut -d"_" -f1`: $line" >> concatoutfile
done < $i
done
here "concatinfile" is the inputfile which contains the list of files to be concated.
"concatoutfile" is the output file
Reg,
Abinaya