Find and cat top lines recursively


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find and cat top lines recursively
# 1  
Old 10-28-2013
Tools Find and cat top lines recursively

I have a folder structure with multiple sub directories
Code:
MAIN
  FOLDER1
    SUBFOLDER1
      files......
  FOLDER2
    SUBFOLDER1
      files......
etc

and I want to find a way to create an output of every files first 20 lines. I've been searching and testing and failing. I can do it in a directory but not a sub-directory

Any help would be great! Thanks
# 2  
Old 10-28-2013
Try:
Code:
find /MAIN -type f -print -exec head -20 {} \;

# 3  
Old 10-28-2013
AWESOME!

bartus11 - that worked perfectly!
Thank you so much for the fast reply!!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find file type recursively and move

Hello, I supposed that it was working fine but now I see that it's not working as expected. I am running under ubuntu14.04, trusty. My plan was to search folderA and all subdirectories and move any txt file to destination folder, folderB : find /home/user/folderA/ -type f -iname "*.txt"... (0 Replies)
Discussion started by: baris35
0 Replies

2. UNIX for Dummies Questions & Answers

Find and rename file recursively

Hi, I have a directory which contains multiple files with .txt extension, i want to rename all these file to .bak extension using find command, this is what i've tried, please help me to correct this : find /home/application/test -name '*.txt' -exec rename 's/txt/bak/' {} \; seems to... (8 Replies)
Discussion started by: mukulverma2408
8 Replies

3. Shell Programming and Scripting

How to find and replace a string with spaces and / recursively?

Hi all, I wanted to find and replace an email id from entire directory structure on a Linux server. I found that find . -type f -print0 | xargs -0 sed -i 's/abc@yahoo.com/xyz@gmail.com/g' would do it perfectly. But my search criteria has extended and now I want to search for a string1 like... (2 Replies)
Discussion started by: pat_pramod
2 Replies

4. Shell Programming and Scripting

Print n lines from top and n lines from bottom of all files with .log extenstion

Oracle Linux 6.4 In a directory I have more than 300 files with the extension .log I want the first 5 and last 5 lines of these .log files to be printed on screen with each file's name. Expected output : Printing first 5 and last 5 lines of FX_WT_Feb8_2014.log !! Authentication... (7 Replies)
Discussion started by: kraljic
7 Replies

5. UNIX for Dummies Questions & Answers

Find command not searching recursively

I'm searching for particular scripts that contain pattern "BASIS" so I used the following command: find . -type f -print | xargs grep "BASIS" or find . -type f -exec grep "BASIS" {} \; However, I found out that the find command in the UNIX box that I'm working on doesn't find files... (6 Replies)
Discussion started by: The Gamemaster
6 Replies

6. Shell Programming and Scripting

Recursively cat files in a directory with filename printed first.

I want to recursively cat the content of files in a directory e.g. find /etc -type f -exec cat {} \; But I want it to print the file name first and then the content. For example let's say /etc/statetab and /etc/colord.conf will be printed first then I want the output to look something like; ... (6 Replies)
Discussion started by: lewk
6 Replies

7. Shell Programming and Scripting

Recursively *.ext files using find

HI, Getting the syntax error " find: missing conjunction" for the below code D1_DIR=/x/y/z D1_NAME=file_name FILE_DIR=pset for file in `find ${D1_DIR}/${D1_NAME} -name "*\.${FILE_DIR}" /dev/null {} \;` do echo $file done #Trying to find all the files with *.pset... (5 Replies)
Discussion started by: cvsanthosh
5 Replies

8. Shell Programming and Scripting

recursively Grep particular words among lines from a file

dear experts, Could you please help me to write a command/script to find follwing: from the log file i want to grep "resCode89270200100001552311" after that only "<resultCode>40614</resultCode>" it will be like that: resCode89270200100001552311 <resultCode>40614</resultCode> ... (7 Replies)
Discussion started by: thepurple
7 Replies

9. Shell Programming and Scripting

how to get only filename in a recursively find command

Hi i would like to ask on how to accomplish the FF: I want to execute a find command recursively and only get the filename something like i want only the last field set if is used ever the fieldvset as an redirection from the output of the find command For example: dir1/dir2/filename1... (2 Replies)
Discussion started by: jao_madn
2 Replies

10. Shell Programming and Scripting

Find the number of non-duplicate names recursively.

Hi, here comes another newbie question: How to find the number of non-duplicate names recursively? For example, my files are stored in the folders like: If I do find . -depth -name "*.txt" | wc -l This will gives out a result "4". One .txt file named "1.txt" in folder "1", and... (2 Replies)
Discussion started by: jiapei100
2 Replies
Login or Register to Ask a Question