I have 10 files and each file contain 100 records and i need to write a script to
merge all the 10 files into a single file.Before merging each file we need to add sequence no in the firstcolumn of each file.
eg:- file1
seq no : 0 -100(100 records in a first file)
file2
seq no :- 101 -200(100 records in a second file)
file 3
seq no :- 201-300(100 records in a third file)
and so on....
finally, we need to merge all 10 files in to a single file.
I like to change your script something like below.
# !/bin/bash
#for i in $(ls dx*) --> use less use of ls command
for i in dx*
do
cat $i >> allnumber.txt
done
# cat allnumber.txt | awk '{ print NR $0 }' > all_number.txt --> useless use of cat
awk '{ print NR $0 }' allnumber.txt > all_number.txt
rm allnumber.txt