Extracting Some fields from current file to another file

Hi,

I have multiple files in a directory all I am trying to do is to read the files in the directory and extract data from 2nd field till 10th field and put it in a new files. The files are pipe delimited. The new file will have the same name as the old file but the prefix of PRE_oldfilename.

I am doing something like this:
 
Cd /export/home/myhomedirectory
 
 
for i in `ls -1 *.txt`
do
echo "Processing file $i"
 
I need to put the code hear to extract data from 2nd field till 10th field and put it in a new file with the prefix PRE_oldfilename.
 
done
 
cut -d"|" -f2-10 file 
1 Like