LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 05-06-2011, 12:57 AM   #1
rakesh.bharad
LQ Newbie
 
Registered: May 2011
Posts: 3

Rep: Reputation: 0
Need to remove / (slash) and replace ; (semi-colon) with new line


Hi,
I am new to unix. and I need to have a shell script which does the following,

1. Remove '/' in the file
2. Replace ';' with new line

Input file (sample):

TL/01039;TL/07014;TL/07016;TL/07046;TL/09476;TL/09522

Output file should be:

TL01039
TL07014
TL07016
TL07046
TL09476
TL09522

Can someone help on this?. I would appreciate if steps involved are explained.

Thanks

Rakesh
 
Old 05-06-2011, 01:03 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You can use tr to change the semi-colons into newline characters. Look at the man page for tr ("man tr") to see how to use it.

To remove the slashes, you can use sed. You might want to look at this tutorial for sed (particularly the "The essential command: s for substitution" section).

Pipes are also useful for this task.

Last edited by Nylex; 05-06-2011 at 01:06 AM.
 
Old 05-06-2011, 02:01 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
You could try a simple awk:
Code:
awk 'gsub("/","")' RS=";" file
 
  


Reply



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
sed command to replace slash with backslash stelmed Slackware 13 08-19-2010 05:01 AM
[SOLVED] expect -- semi-colon in password being translated. bartonski Linux - Software 8 09-13-2009 09:04 AM
How to identify a line and replace another string on that line using Shell script? Sid2007 Programming 10 10-01-2007 08:49 PM
need a semi colon .. but vert spooge Linux - General 4 09-19-2004 03:52 PM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM

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

All times are GMT -5. The time now is 07:33 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