LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-13-2022, 08:00 AM   #31
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled

Quote:
Originally Posted by NevemTeve View Post
Here is an idea you might find familiar from earlier:
Code:
find /app -name '*temp.txt' -type f |\
while read Name; do echo "=== $Name ==="; cat -- "$Name"; done
I tried and i get output as , i also wanted to check subdirectories under app

Code:
./update.sh: line 2:  : command not found
find: ‘/app/oracle/s1’: Permission denied
find: ‘/app/payless’: Permission denied
f

===  ===
cat: : No such file or directory

===  ===
cat: : No such file or directory

===  ===
cat: : No such file or directory

===  ===
cat: : No such file or directory

===  ===

Last edited by 1s440; 06-13-2022 at 08:15 AM.
 
Old 06-13-2022, 08:19 AM   #32
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,880
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Kindly insert your update.sh script here, my mind-reading powers doesn't work on Mondays.
Nonetheless the files and directories you are not allowed to read can be safely omitted:
Code:
find ~/tmp/app -name '*temp.txt' -type f -readable 2>/dev/null |\
while read Name; do echo "=== $Name ==="; cat -- "$Name"; done

Last edited by NevemTeve; 06-13-2022 at 08:22 AM.
 
Old 06-13-2022, 08:21 AM   #33
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,828

Rep: Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216Reputation: 1216
Quote:
Originally Posted by 1s440 View Post
I am not sure how can i explain in betterway:

Code:
find /app -name '*temp.txt' -print -exec cat {} +  > files.list
you get output

Code:
/app/tmp/folder/temp.txt
/app/oracle/scp/temp.txt

--- ouput of temp.txt file

--- ouput of temp.txt file
is there a way that we get output of each txt files for ex: to be readable easily
Code:
/app/tmp/folder/temp.txt

--- ouput of txt file
/app/oracle/scp/temp.txt

--- ouput of txt file
Indeed the -print prints the filenames immediately, while the + causes bundling/delaying of the -exec cat
Simple fix:
Code:
find /app -name '*temp.txt' -print -exec cat {} \;  > files.list
The \; causes an immediate exec of cat
 
1 members found this post helpful.
Old 06-13-2022, 08:40 AM   #34
1s440
Member
 
Registered: Mar 2018
Posts: 266

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
Indeed the -print prints the filenames immediately, while the + causes bundling/delaying of the -exec cat
Simple fix:
Code:
find /app -name '*temp.txt' -print -exec cat {} \;  > files.list
The \; causes an immediate exec of cat
perfect. Thank you. it worked. so this will also include subdirectories search right

Last edited by 1s440; 06-13-2022 at 08:48 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash Issue with Find Script: find paths must precede expression: *.txt JockVSJock Programming 4 01-06-2014 09:03 PM
Bash problem : -bash: [: /bin/bash: unary operator expected J.A.X Linux - Software 1 09-22-2011 05:52 AM
bash my little bash alaios Linux - Newbie 4 01-10-2005 11:59 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration