LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 03-13-2012, 04:38 PM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 268
Blog Entries: 7

Rep: Reputation: 18
horizontal to vertical


Hi all,

Assume that i have following text in a text file

centos redhat fedora ubuntu

I want these to be arranged like this

centos
redhat
fedora
ubuntu

Means that the text seperated by spaces needs to be ordered in the above manner.Is there any automatic way of doing so or using any single command.

Your suggestions please
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 03-13-2012, 04:47 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Try this:

Code:
tr ' ' '\n' <file
 
2 members found this post helpful.
Old 03-13-2012, 04:50 PM   #3
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, Ubuntu, SLES, CentOS
Posts: 1,790

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
@ Reply

Hi dinakumar12

This will require little bit of scripting as follows:
Code:
#!/bin/bash
for i in `cat filename`
do
	echo $i
done
Edit: David the H. suggestion is much better than this one

Last edited by T3RM1NVT0R; 03-13-2012 at 04:55 PM.
 
1 members found this post helpful.
Old 03-13-2012, 04:55 PM   #4
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 268
Blog Entries: 7

Original Poster
Rep: Reputation: 18
Hi Thanks,

That works great.
 
  


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
Horizontal and Vertical sync rates?? chris24300 Linux - Newbie 5 09-08-2009 05:18 PM
mouse goes vertical; not horizontal (slack) nadroj Linux - Newbie 22 10-30-2006 03:09 AM
NVIDIA - Horizontal/Vertical Adjust JamboUK Ubuntu 4 05-19-2006 06:52 AM
Horizontal and vertical refresh sharpie General 5 01-24-2004 08:17 PM
Horizontal and vertical refresh rate johannes Linux - Laptop and Netbook 3 10-31-2003 06:44 AM


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