Can someone help me?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can someone help me?
# 1  
Old 03-04-2008
Can someone help me?

Dear friends,

My ETL is generating 10-15 files per day based on incoming values for the Product IDs. Someone has posted solution for on file but I need it for multiple files.

Following is the example of one file, i want to remove 1st columns from all the files in this folder,

example

File Name : ProductCIN.txt
Data:
23478 DFG XCV ERT 12
23478 DFG CBN EDC 18
34599 XDS EDF ERT 10
98789 SER FGH RGS 23

Convert to

DFG XCV ERT 12
DFG CBN EDC 18
XDS EDF ERT 10
SER FGH RGS 23
for all the files.

thanks
Monica
# 2  
Old 03-04-2008
Code:
find /path/to/my/folder -type f |\
while read filename 
do
      awk '{ for(i=2; i <NF; i++) {printf("%s ",$i)}
                    print $NR 
             } ' $filename > tmpfile
      mv tmpfile $filename
done

TEST this code first to see if it does what you need.
# 3  
Old 03-06-2008
Hope this should Work!!!!!!!!!!!!!!!!!!!!

awk '{$1="";print}' filename
# 4  
Old 03-06-2008
Code:
for i in *
do
awk '{
for(i=2;i<=NF;i++)
printf("%s ",$i)
print ""
}' $i 
done

# 5  
Old 03-06-2008
You can also use sed

Code:
while read filename 
do
      sed -e 's/\(^[1-9]* \)//' $filename > tmpfile
      mv tmpfile $filename
done

# 6  
Old 03-06-2008
It's not clear (at least for me Smilie) if the file content includes the first two records:

Code:
File Name : ProductCIN.txt
Data:

If yes:

Code:
perl  -i.bck -pe's/\S* // if $. > 2;close ARGV if eof' file1 file2 ... # or *

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question