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 jgt 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-12-2017
jgt's Unix or Linux Image
jgt jgt is online now Forum Advisor  
Registered User
 
Join Date: Apr 2007
Last Activity: 20 October 2017, 3:40 PM EDT
Location: 44.21.48N 80.50.15W
Posts: 1,989
Thanks: 2
Thanked 268 Times in 251 Posts
Try using bash substrings:

Code:
#run interactively
 a="2017-07-12_gmr_tag_log_20170711.csv" 
 echo $a                                 
#remove the first 11 characters           
b=${a:11}                               
echo $b
#set l to the length of string b
 l=${#b}                                 
echo $l
#set s to the middle length of string b
let s=$l-13                             
echo $s
#set c to the middle part of the string  
c=${b:0:$s}                             
echo $c                                 
#concatenate string c and ".csv"         
d=$c.csv                                
echo $d