LinuxQuestions.org
Register a domain and help support LQ
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, 01: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, 02: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 02:06 AM.
 
Old 05-06-2011, 03:01 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,421

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


Reply


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


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