nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Create output in columns

This is a discussion on Create output in columns within the Shell scripting forums, part of the Development/Scripting category; Hi All, I have a txt file as below Rakesh Pune satara road, pune. 12345678 Married Now I want o/p ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 09-17-2007, 10:32 AM
Junior Member
User
 
Join Date: Sep 2007
My distro: Linux
Posts: 3
Rep Power: 0
rakeshrhn is on a distinguished road
Default Create output in columns

Hi All,

I have a txt file as below
Rakesh
Pune satara road, pune.
12345678
Married

Now I want o/p as below:
Name Address Phone Number Status

Rakesh Pune satara road, pune. 12345678 Married

I was unable to create such o/p using column -t, So how can I align the o/p using shell scripting. I will using this script in both Linux and Solaris.

Thanks in Advance.

Last edited by rakeshrhn; 09-17-2007 at 10:46 AM..
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-19-2007, 11:45 AM
Junior Member
User
 
Join Date: Sep 2007
My distro: Linux
Posts: 3
Rep Power: 0
rakeshrhn is on a distinguished road
Default

HI Experts,

Can you help me in above request ?


Thanks
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 09:08 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

How many recored are in files? Is format always fix ? You can do that with shell scripting and awk or any other tools.. let me know the details
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #4 (permalink)  
Old 10-17-2007, 11:13 AM
Junior Member
User
 
Join Date: Sep 2007
My distro: Linux
Posts: 3
Rep Power: 0
rakeshrhn is on a distinguished road
Default

Hi,

Only 4 rows are there with space and comma seperated.

Thanks,
Bharat
Reply With Quote
  #5 (permalink)  
Old 11-01-2007, 05:51 PM
Member
User
 
Join Date: Oct 2007
My distro: Linux RHEL 5
Posts: 33
Rep Power: 0
vikas027 is on a distinguished road
Default

You should be more specific, always add quotes and exapmples in ur prob, it is easier to understand, and reply. I am doing it for you.

Quote:
Hi All,

I have a txt file as below
file1.txt
Quote:
Rakesh
Pune satara road, pune.
12345678
Married
Now I want o/p as below:

file2.txt
Quote:
Name Address Phone Number Status
Hi Rakesh,
I am also a newbie. Well one solution to ur problem is :--

use this code
Code:
touch file3.txt
(for text in `cat file1.txt`;
do
echo -e -n "\b$text " >> file3.txt
done;)
Add spaces or tabs according to your need.

This will result in file3.txt
Quote:
Rakesh Pune satara road, pune. 12345678 Married
Now u can easily cat file2.txt file3.txt

Hope it helps.
Reply With Quote
  #6 (permalink)  
Old 12-07-2007, 07:27 PM
anilvrathod's Avatar
Junior Member
User
 
Join Date: Dec 2007
Location: Pune
My distro: Red Hat
Posts: 13
Rep Power: 0
anilvrathod is on a distinguished road
Lightbulb

Dear Friend
Try this

touch file3.txt
(for text in `cat file1.txt`;
do
echo -e -n "\b$text " >> file3.txt
printf "% 4d" ("\b$text " >> file3.txt)
done

Anil V. Rathod
Linux System Administrator
Kalinga Data Link pvt.Ltd.
pune -satara road ,pune.
cell no. 9860062917
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
match the columns of 2 files and merge common rows piyali_biobase Shell scripting 0 11-05-2007 07:34 PM
Mysql how to specify select columns raj Databases servers 2 12-19-2006 02:23 AM
help me in editing this columns sureshbup Shell scripting 1 12-12-2006 03:29 PM
rearranging columns in a text file sureshbup Shell scripting 2 12-06-2006 10:43 AM
Calculations across different lines & columns of a file Guest Shell scripting 2 09-16-2005 05:18 AM


All times are GMT +5.5. The time now is 06:04 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36