LinuxQuestions.org
Visit Jeremy's Blog.
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 03-13-2012, 03:38 PM   #1
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
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, 03:47 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Try this:

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

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ 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 03:55 PM.
 
1 members found this post helpful.
Old 03-13-2012, 03:55 PM   #4
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271

Original Poster
Blog Entries: 7

Rep: Reputation: 18
Hi Thanks,

That works great.
 
  


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

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

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