another textprocessing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting another textprocessing
# 8  
Old 02-28-2011
Yes , I'm not checking whether the filename is coming after update or not and just placing date-part/file_name
# 9  
Old 02-28-2011
See if this works for you:
Code:
sed 's#\(.*/\)\(.*_\)\(.*\).txt#\1\3/\2\3.txt#'  inp_file

# 10  
Old 03-01-2011
Quote:
Originally Posted by panyam
Just a change to the solution suggested above

Code:
 
sed -r 's/.*_([0-9]+).txt/\1\/&/'

Thanks for the help..I think I make a basic mistake with the path/filename because on each suggestion I tried I receive always the same error message:

/inputfile/data/xxx/yyy/update/name_20110127.txt,128,EPF,11 not found

so I implement the path:
Code:
$directory/input.txt sed -e 's|/[^/]*_\([0-9]*\).txt|/\1&|'



Jurgen

---------- Post updated at 05:42 AM ---------- Previous update was at 05:29 AM ----------

Quote:
Originally Posted by pravin27
How about this,
Code:
 perl -nle 's/\/(\w+)(\d{8})/\/\2\/\1\2/;print $_;' inputfile

thanks for the answer..
the perl stuff seems to work (from the shell output) but the sourcefile input.txt is the same like before...there is no overwrite of the file


jurgen
# 11  
Old 03-01-2011
Below code will take backup of inputfile as inputfile.old before processing and then modify the inputfile
Code:
perl -p -i.old -nle 's/\/(\w+)(\d{8})/\/\2\/\1\2/' inputfile

This User Gave Thanks to pravin27 For This Post:
# 12  
Old 03-01-2011
Quote:
Originally Posted by pravin27
Below code will take backup of inputfile as inputfile.old before processing and then modify the inputfile
Code:
perl -p -i.old -nle 's/\/(\w+)(\d{8})/\/\2\/\1\2/' inputfile

thanks for you usefull help. It seems to work on the example I sent (I will do some tests and I hope its will work on each different line I have,- its not really clear for me what you are doing, especially in the second part of the line "\d{8})/\/\2\/\1\2/'")...Smilie


Jurgen

---------- Post updated at 07:51 AM ---------- Previous update was at 07:45 AM ----------

Quote:
Originally Posted by pravin27
Below code will take backup of inputfile as inputfile.old before processing and then modify the inputfile
Code:
perl -p -i.old -nle 's/\/(\w+)(\d{8})/\/\2\/\1\2/' inputfile

There is still one issue....in the outputfiles is each line double. Smilie
Login or Register to Ask a Question

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