Cat of rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cat of rows
# 1  
Old 01-18-2009
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 Smilie

Last edited by kalius88; 01-18-2009 at 12:25 PM..
# 2  
Old 01-18-2009
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  
Old 01-18-2009
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  
Old 01-18-2009
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  
Old 01-18-2009
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  
Old 01-18-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

2. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

3. Shell Programming and Scripting

combining cat output and cutting rows

I have a file that contain the following. -D HTTPD_ROOT="/usr/local/apache" -D SERVER_CONFIG_FILE="conf/httpd.conf" I want a shell script, so that after cat filename and apply the shell script I should get the output as follows. /usr/local/apache/conf/httpd.conf ie cat filename |... (7 Replies)
Discussion started by: anilcliff
7 Replies

4. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

5. Shell Programming and Scripting

Remove 1st two rows and last 2 rows

Hi All, I need to remove 1st 2 line from head and last 2 line from last. I thought it would be possible by using the Head and tail command. But after i am using it is not possible by it. Example:Input file 1 2 3 4 5 Example: Output file 3 But my head and tail command are not... (12 Replies)
Discussion started by: kam786sim
12 Replies

6. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

7. UNIX for Dummies Questions & Answers

Converting rows into multiple-rows

Hi every one; I have a file with 22 rows and 13 columns which includes floating numbers. I want to parse the file so that every five columns in the row would be a new record (row). For example, the first line in the old file should be converted into three lines with first two lines contain 5... (6 Replies)
Discussion started by: PHL
6 Replies

8. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

9. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies
Login or Register to Ask a Question