LinuxQuestions.org
Review your favorite Linux distribution.
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 11-21-2012, 04:10 PM   #1
fortelr0923
LQ Newbie
 
Registered: Jul 2012
Posts: 3

Rep: Reputation: Disabled
inserting \n after each character


I'd like to change a unix file from:

bird
cat
dog

to:

b
i
r
d

c
a
t

d
o
g

Is the sed the best answer?

Thanks.
 
Old 11-21-2012, 04:14 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
I don't know if it's the best tool, but it will work. It can be also done with awk, tr, perl, etc....

Markus
 
Old 11-21-2012, 06:52 PM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 619

Rep: Reputation: 42
it can easily be done with sed:

Code:
sed 's/\(.\)/\1\n/g'-i filename
 
  


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
Inserting a '#' hash comment character in a dhcpd.conf rhbegin Programming 4 10-09-2012 10:23 AM
Writing a file character by character with a bash builtin command (script). stf92 Linux - Newbie 4 06-30-2012 08:41 PM
Inserting a special character with the keyboard #2 Schreiberling Linux - General 1 06-11-2006 03:57 PM
Question about inserting a character into a 2dimensional sequence. RHLinuxGUY Programming 6 11-27-2005 10:52 PM


All times are GMT -5. The time now is 02:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration