×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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 11-14-2017
SkySmart SkySmart is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 12 July 2018, 10:14 AM EDT
Posts: 919
Thanks: 757
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.