Unix/Linux Go Back    



Replace space within quotes

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member SkySmart Regarding:
Replace space within quotes.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 3 Days Ago   -   Original Discussion by SkySmart
SkySmart SkySmart is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 15 November 2017, 11:03 PM EST
Posts: 897
Thanks: 735
Thanked 3 Times in 3 Posts
Replace space within quotes

i have an output that i receive and it looks like this:


Code:
echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily Inventory Sync-en-us.csv' '/var/FTPROOT/px/sci/archive/20171102070058291-DY_DC07_Daily Inventory Sync-en-us.csv'

what i want to do is replace the spaces in the file names with asterisks "*".

end result should be:


Code:
echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily*Inventory*Sync-en-us.csv' '/var/FTPROOT/px/sci/archive/20171102070058291-DY_DC07_Daily*Inventory*Sync-en-us.csv'

i tried with this:


Code:
echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily Inventory Sync-en-us.csv' '/var/FTPROOT/px/sci/archive/20171102070058291-DY_DC07_Daily Inventory Sync-en-us.csv' | sed 's~ ~*~g'

but of course, this will replace all the spaces with asterisks. which is not what i want. i only want the spaces within the single quotes to be replaced with an asterisk.