The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
String substitution on find results inside exec/xargs myndcraft Shell Programming and Scripting 2 05-17-2008 02:36 PM
Problem using find and xargs quixote Shell Programming and Scripting 5 05-02-2008 10:24 PM
command usage on find with xargs and tar darkrainbow AIX 3 12-25-2007 06:25 PM
strange behavior of find with xargs jerardfjay Shell Programming and Scripting 9 08-09-2007 08:06 AM
xargs jpprial UNIX for Dummies Questions & Answers 4 09-17-2001 08:29 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-15-2005
asal_email asal_email is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 9
find | xargs cat

Hai I just want to find a file *.txt in particular direcotry and display the file name puls the content. Do someone know hot to do this, thanks.

I try :
find test/ -name '*.txt' | xargs cat

but It does'nt print out the file name, i want something below print out in my screen :

test/1.txt
this is content of 1.txt
test/2.txt
this is content of 2.txt
... so on

instead of :

this is content of 1.txt
this is content of 2.txt
... so on, which is what my previous script does.

Thanks for your help
  #2 (permalink)  
Old 03-15-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
| xargs head -1000000
  #3 (permalink)  
Old 03-15-2005
asal_email asal_email is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 9
thx

Thanks, it really works. but when I want to put in standard output it takes a very slow processing.

Do u know other way using sed or awk ?
since I want to print other thing after the file name and save in standard ouput e.g:

test/1.txt
new text at beginning
content of 1.txt
new text at ending
test/2.txt
new text at beginning
content of 2.txt
new text at ending

the new text at beginning and new text at ending will be the same for every file.

Last edited by asal_email; 03-15-2005 at 04:54 AM.. Reason: what is -1000000 for ?
  #4 (permalink)  
Old 03-16-2005
sglinux sglinux is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 6
find

How about trying this one....


find . -type f -name *.txt -print

Let me know does it work for you or not.....
  #5 (permalink)  
Old 03-17-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Code:
 ksh/bash

for file in $(find test -type f -name "*.txt") ; do
    echo ${file}
    echo "New text at the start"
    cat ${file}
    echo "new text at the end"
done
Closed Thread

Bookmarks

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 03:48 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