LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 09:31 PM   #1
gaurvrishi
Member
 
Registered: Apr 2012
Posts: 62

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, 09:36 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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, 10:49 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
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, 12:51 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
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, 03:19 AM   #5
gaurvrishi
Member
 
Registered: Apr 2012
Posts: 62

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

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
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 05:31 PM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
Sed command - command garbled errror gauavmahesh Linux - Newbie 3 03-30-2012 10:04 PM
Modifying text file with "one command line" SED command... daleo Linux - Newbie 3 01-13-2012 05:32 AM
sed command shyamdey Programming 2 08-29-2006 11:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:01 PM.

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
Open Source Consulting | Domain Registration