I have a list of files in the same directory need to do the following
cut -d "=" f2 file1 > file1_result
cut -d "=" f2 file2 > file2_result
...
past file1_result file2_result .... >file_sum
How to do this in a loop? Thank you.
I have a list of files in the same directory need to do the following
cut -d "=" f2 file1 > file1_result
cut -d "=" f2 file2 > file2_result
...
past file1_result file2_result .... >file_sum
How to do this in a loop? Thank you.
Do you mean:
cut -d "=" -f2 file1 > file1_result
cut -d "=" -f2 file2 > file2_result
...
paste file1_result file2_result .... >file_sum
What is the maximum number of input files ?
Is there any way that the files called file* can be in a different directory from the files called file*_result ?
Yes, you are right with the red colored correction.
total input files is about 10-20 files
Yes, file* can be in different directory for file*_result.
Do you have any idea how to proceed using loop? Thanks a lot
mkdir output
for FILE in input/*
do
# Strip input/ from FILE to make OUTNAME
OUTNAME=$(basename "$FILE")
# Cut reading from $FILE writing to output/${OUTNAME}
cut -d "=" f2 "$FILE" > "output/${OUTNAME}"
done
paste output/* > file_sum