Unix/Linux Go Back    

Remove the leading and trailing date from a CSV file

Shell Programming and Scripting

Kindly Note - This is a Single User Post by Forum Member shivamayam Regarding:
Remove the leading and trailing date from a CSV file.
Please Follow The Primary Link Above to View the Full Discussion.

Old Unix and Linux 07-13-2017   -   Original Discussion by shivamayam
shivamayam's Unix or Linux Image
shivamayam shivamayam is offline
Registered User
Join Date: Jan 2013
Last Activity: 11 October 2017, 12:51 PM EDT
Posts: 10
Thanks: 2
Thanked 0 Times in 0 Posts
I'm using a shell script. I have extracted today files to a directory1 and date should be removed on both sides of a CSV file.

FYI... I'm looking to remove the date from the file name and not inside the CSV file.



Final output Directory2:


---------- Post updated at 09:30 AM ---------- Previous update was at 03:52 AM ----------

I used the below script and it removed the trailing date. How to remove the leading date ?

ls -1 *.csv | awk '{print "mv " $1 " final/"$1}' | sed -E 's/([[:alpha:]]+)_[^_]+(\.csv)/\1\2/2' | csh

Any help is much appreciated.

Last edited by shivamayam; 07-13-2017 at 07:33 AM..