The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Merging of rows ssachins Shell Programming and Scripting 24 01-06-2009 11:40 AM
Cut rows obedkhan HP-UX 2 08-23-2006 10:36 AM
Finding different rows dombi Shell Programming and Scripting 2 03-06-2006 05:01 PM
Difference between two rows JimJim Shell Programming and Scripting 7 07-05-2005 08:52 AM
Concatenate 2 rows into 1 row indianadoug Shell Programming and Scripting 4 03-11-2005 11:05 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-18-2009
kalius88 kalius88 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 4
Cat of rows

Hello, I'm starting from the scratch with Unix, and I was wondering if you could give me an answer for this problem...

I've got a column with different names of files, something like:
./file1
./file2
...
Now, I would like to show the content of each file. The column with the names comes from a pipeline, but I think that doesn't matter in this case.

Of course I know about "cat", but if I type "....commands wich generate the above column.... | cat " the result is just the same.

Thanks in advance.

P.D. I know it's easy, but I'm so noob

Last edited by kalius88; 01-18-2009 at 12:25 PM..
  #2 (permalink)  
Old 01-18-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
I am not actually sure what you are asking. I understand that you will have a column of file names.. are you just wanting to cat those files and display the output?


Code:
echo -e "test2.txt\ntest.txt\ntest.txt.bak" | xargs cat

The echo will output those few files, one on each line, and the results are piped to xargs ( man xargs ), and xargs executes cat on each of the files, displaying the results of each.
  #3 (permalink)  
Old 01-18-2009
kalius88 kalius88 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 4
Yes, that's the point. But, actually, I'm working with Plan9, wich is not exactly Unix, and xargs does not exist here. Anyway thank you for your help. I will think about how I could do it in other way.
  #4 (permalink)  
Old 01-18-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
well if you can't do it that way, you can do it like..


Code:
for file in `get list of files here`; do
    cat $file;
done

Inside of where you see 'get list of files here', replace it with how you get your files.
  #5 (permalink)  
Old 01-18-2009
kalius88 kalius88 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 4
Thank you so much. I was trying something like your for, but I didn't really know how I could put my pipelines into my 'get list of files here'.

Anyway that problem belongs to the past, because of you. Thank you.
  #6 (permalink)  
Old 01-18-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
haha, no problem, basically inside of the backticks, you can do any shell commands.. you just need to make sure it returns the list of files.
Closed Thread

Bookmarks

Tags
cat, column, file

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 06:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0