Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 05-11-2005, 05:31 AM   #1
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Rep: Reputation: 15
Question Table format with ShellScript

From within the shellscript I'd like first to create a file with a table containing two headers( path-name, type) and then feed those columns with the result from the following code:

file $1/*|tee list_file

The final result should look something like that but with more space between the headers and columns :

path-name type
/home/file ASCII
/home/file2 Texte file
/home/file3.htm HTML document text

I tried the following code but that doesn't do the trick:

file $1/*|tee list_file | awk 'BEGIN {print "Path-Name\t\t\tType\n--------------------------------------------"} {print $1"\t"$2} \
END {print "-----------------------------"}' list_file
Help! Thanks
Old 05-11-2005, 05:46 AM   #2
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
Look into awk's ability to handle fixed-width fields.

Old 05-11-2005, 06:39 AM   #3
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
Hello Yves,

The truth is that I 've been unable to get the table with the ouput content. I tried that but it still don't work:


file $1/*|tee file_list 

awk 'BEGIN { print "Path-Name Type"
 	     print "--------- -----"}
	   { print $1, "      ", $2 }' file_list


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
alternate partition table format for linux trabant Linux - Software 0 09-21-2005 08:27 AM
Help Shellscript paraiso Linux - Newbie 7 05-12-2005 07:25 AM
shellScript help paraiso Linux - Newbie 2 05-10-2005 07:09 PM
ShellScript sharadgana Programming 1 12-16-2004 01:16 PM
Changing date format in MySQL table vous Linux - Software 8 09-03-2003 06:30 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:02 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration