03-17-2009
find | xargs cat
Hi,
I am having trouble getting a combination of commands to work.
I need to traverse through all sub-directories of a certain directory and 'cat' the contents of a particular file in the sub-directories.
The commands on their own work but when I combine them I get no output.
The command I am trying to get working is:
find . -type f -name "developer.txt" | xargs cat
The find command works correctly and when I copy and paste the output of that with a preceeding 'cat', the contents are printed out. However together with the pipe the commands are not working.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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... (4 Replies)
Discussion started by: asal_email
4 Replies
2. Shell Programming and Scripting
I'm using Imagemagick to create thumbnails for a large directory tree. The only thing I can't see is how to get it to write the thumbnails to a "thumbs" subdirectory!
Either of these two commands from the Imagemagick site does most of the job:
find -name '*.jpg' | xargs -n1 sh -c 'convert $0... (5 Replies)
Discussion started by: quixote
5 Replies
3. UNIX for Dummies Questions & Answers
I am trying to delete files older than 60 days from a folder:
find /myfolder/*.dat -mtime +60 -exec rm {} \;
ERROR - argument list too long: find
I can't just give the folder name, as there are some files that I don't want to delete. So i need to give with the pattern (*.dat). I can... (3 Replies)
Discussion started by: risshanth
3 Replies
4. Shell Programming and Scripting
hi,
i've been trying to figure this weird error but I cannot seem to know why. I am using below find command:
find . \( ! -name . -prune \) -type f -mtime +365 -print
The above code returns no file because no files are really more then 365 days old. However, when I use xargs, its... (9 Replies)
Discussion started by: The One
9 Replies
5. UNIX for Dummies Questions & Answers
I am trying to find all the files listed in a filelist.txt.
Why cant I use something like this
cat filelist.txt | xargs -n1 find $path (2 Replies)
Discussion started by: dragonpoint
2 Replies
6. Shell Programming and Scripting
Guys i want to run a command to list all directories that havn't been modified in over 548 days ( 1.5 yrs ).
Id like to run a script to first print what the command finds ( so i get a list of the files pre move ... i have a script set for this :
find /Path/Of\ Target/Directory/ -type d -mtime... (4 Replies)
Discussion started by: modulartention
4 Replies
7. UNIX for Dummies Questions & Answers
How can I recursively find all files in a directory and print out the file and first line number of any text blocks that match the below cases?
This would seem to involve find, xargs, *grep, regex, etc.
In summary, I want to find so-called empty "try-catch blocks" that do not contain code... (0 Replies)
Discussion started by: lifechamp
0 Replies
8. Shell Programming and Scripting
Hi All,
i'm trying to create a tar of all the .txt files i find in my dir . I've used xargs to acheive this but i wanted to do this with exec and looks like it only archives the last file it finds . can some one advice what's wrong here :
find . -type f -name "*.txt" -print0 | xargs -0... (9 Replies)
Discussion started by: Irishboy24
9 Replies
9. Shell Programming and Scripting
Hi,
I want to find some files and then search for some lines in it with a particular pattern and then write those lines into a file. To do this I am using something like this from command prompt directly.
cd /mdat/BVG
find -name "stmt.*cl" -newer temp.txt | xargs -i awk '/BVG-/{print}' {} >... (7 Replies)
Discussion started by: Sandhya Harsh
7 Replies
10. UNIX for Beginners Questions & Answers
Hi, I'm new here and this is my first post. I used command line Unix at work for 3 years... about 10 years ago! Now I can't figure out nor hunt down examples of how to do the following:
Say I built a list of file to backup like this:
find ~ -name "*.pdf" -print >> MYPDF.txt
So I am using find... (6 Replies)
Discussion started by: hwilliam777
6 Replies
CAT(1) BSD General Commands Manual CAT(1)
NAME
cat -- concatenate and print files
SYNOPSIS
cat [-belnstuv] [file ...]
DESCRIPTION
The cat utility reads files sequentially, writing them to the standard output. The file operands are processed in command-line order. If
file is a single dash ('-') or absent, cat reads from the standard input. If file is a UNIX domain socket, cat connects to it and then reads
it until EOF. This complements the UNIX domain binding capability available in inetd(8).
The options are as follows:
-b Number the non-blank output lines, starting at 1.
-e Display non-printing characters (see the -v option), and display a dollar sign ('$') at the end of each line.
-l Set an exclusive advisory lock on the standard output file descriptor. This lock is set using fcntl(2) with the F_SETLKW command.
If the output file is already locked, cat will block until the lock is acquired.
-n Number the output lines, starting at 1.
-s Squeeze multiple adjacent empty lines, causing the output to be single spaced.
-t Display non-printing characters (see the -v option), and display tab characters as '^I'.
-u Disable output buffering.
-v Display non-printing characters so they are visible. Control characters print as '^X' for control-X; the delete character (octal
0177) prints as '^?'. Non-ASCII characters (with the high bit set) are printed as 'M-' (for meta) followed by the character for the
low 7 bits.
EXIT STATUS
The cat utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
The command:
cat file1
will print the contents of file1 to the standard output.
The command:
cat file1 file2 > file3
will sequentially print the contents of file1 and file2 to the file file3, truncating file3 if it already exists. See the manual page for
your shell (e.g., sh(1)) for more information on redirection.
The command:
cat file1 - file2 - file3
will print the contents of file1, print data it receives from the standard input until it receives an EOF ('^D') character, print the con-
tents of file2, read and output contents of the standard input again, then finally output the contents of file3. Note that if the standard
input referred to a file, the second dash on the command-line would have no effect, since the entire contents of the file would have already
been read and printed by cat when it encountered the first '-' operand.
SEE ALSO
head(1), more(1), pr(1), sh(1), tail(1), vis(1), zcat(1), fcntl(2), setbuf(3)
Rob Pike, "UNIX Style, or cat -v Considered Harmful", USENIX Summer Conference Proceedings, 1983.
STANDARDS
The cat utility is compliant with the IEEE Std 1003.2-1992 (``POSIX.2'') specification.
The flags [-belnstv] are extensions to the specification.
HISTORY
A cat utility appeared in Version 1 AT&T UNIX. Dennis Ritchie designed and wrote the first man page. It appears to have been cat(1).
BUGS
Because of the shell language mechanism used to perform output redirection, the command ``cat file1 file2 > file1'' will cause the original
data in file1 to be destroyed!
The cat utility does not recognize multibyte characters when the -t or -v option is in effect.
BSD
January 29, 2013 BSD