LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-08-2012, 10:31 PM   #1
gaurvrishi
Member
 
Registered: Apr 2012
Posts: 51

Rep: Reputation: Disabled
Wink 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/
 
Old 07-08-2012, 10:36 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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.
 
1 members found this post helpful.
Old 07-08-2012, 11:49 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,245

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
I am guessing this is a made up example, but still struggle to see any practicality to performing the task
 
1 members found this post helpful.
Old 07-09-2012, 01:51 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Thinking laterally, could be a homework task to 'encourage' students to discover that you don't have to use '/' as the separator in sed ... ?
 
1 members found this post helpful.
Old 07-09-2012, 04:19 AM   #5
gaurvrishi
Member
 
Registered: Apr 2012
Posts: 51

Original Poster
Rep: Reputation: Disabled
Solved
 
Old 07-09-2012, 06:40 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,245

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
See the Thread Tools at the top of question to mark as SOLVED.
 
  


Reply

Tags
command line


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sed gives :sed: -e expression #1, char 1: unknown command: `'' samasat Linux - Newbie 10 06-09-2012 06:31 PM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 01:27 PM
Sed command - command garbled errror gauavmahesh Linux - Newbie 3 03-30-2012 11:04 PM
Modifying text file with "one command line" SED command... daleo Linux - Newbie 3 01-13-2012 06:32 AM
sed command shyamdey Programming 2 08-30-2006 12:06 AM


All times are GMT -5. The time now is 02:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration