LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   sed command (https://www.linuxquestions.org/questions/linux-newbie-8/sed-command-4175415609/)

gaurvrishi 07-08-2012 09:31 PM

sed command
 
Hi,

Can you please tell how how can i use sed command so that the result can show like this. I wan to give space after every "/". Please help me in this

Actual: /var/htm/www/g/dsfsfd/wqwqawed/acac/

Result : /var/ htm/ www/ g/ dsfsfd/ wqwqawed/ acac/

evo2 07-08-2012 09:36 PM

Hi,

Code:

echo "/var/htm/www/g/dsfsfd/wqwqawed/acac/" | sed 's%/%/ %g'
This will (s)earch for "/" and replace with "/ " for all occurances: ie (g)lobally.

This does what you asked, but your example "Result" does not put a space after the first "/".

Evo2.

grail 07-08-2012 10:49 PM

I am guessing this is a made up example, but still struggle to see any practicality to performing the task :(

chrism01 07-09-2012 12:51 AM

Thinking laterally, could be a homework task to 'encourage' students to discover that you don't have to use '/' as the separator in sed ... ?

gaurvrishi 07-09-2012 03:19 AM

Solved

grail 07-09-2012 05:40 AM

See the Thread Tools at the top of question to mark as SOLVED.


All times are GMT -5. The time now is 06:07 PM.