find and file info

This first command returns file information, and the second returns all the directories with that filename, so
how would i put these together and execute the command in one.

wc -l -c INPUTFILE_FF | awk '{l=length();if(max < l){max=l};i++}END{print "Num. of lines:\t"i"\nLongest line:\t"l"\nEst. Filesize:\t"i*l"\n"}' INPUTFILE_FF


find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -exec ls -la {} \; | more
mmatharuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ahoffmannCommented:
write following script (3 lines) and name it your-script.sh:

#!/bin/sh
wc -l -c $1 | awk '{l=length();if(max < l){max=l};i++}END{print "Num. of lines:\t"i"\nLongest line:\t"l"\nEst. Filesize:\t"i*l"\n"}'
ls -la $1

chmod 555 your-script.sh
find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -exec /full/path/to/your-script.sh {} \;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
XoFCommented:
find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -print | while read line;do wc -l -c $line | awk '{l=length();if(max < l){max=l};i++}END{print "File info:\n'`ls -la $line`'\nNum. of lines:\t"i"\nLongest line:\t"l"\nEst. Filesize:\t"i*l"\n"}';done

HTH,
-XoF-
root_startCommented:
Hi mmatharu,

You can do this in two ways:

1. The one XoF suggested:
===============================================================
find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -print 2>> /dev/null | while read line
do
  wc -l -c $line | awk '{l=length();if(max < l){max=l};i++}END{print "File info:\n'`ls -la $line`'\nNum. of lines:\t"i"\nLongest line:\t"l"\nEst.  Filesize:\t"i*l"\n"}'
done
===============================================================

Or you can use "for":
===============================================================
for file in `find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -print 2>> /dev/null`
do
  wc -l -c $file | awk '{l=length();if(max < l){max=l};i++}END{print "File info:\n'`ls -la $file`'\nNum. of lines:\t"i"\nLongest line:\t"l"\nEst.  Filesize:\t"i*l"\n"}'
done
===============================================================

Also, do not forget to redirect the standard error output to "/dev/null", otherwise you can have an error an it will be reported during your script execution:
===============================================================
find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -print 2>> /dev/null
===============================================================

I hope it helps.
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

XoFCommented:
> for file in `find /usr/dstage/data/Basel2/work -name "INPUTFILE_FF" -print 2>> /dev/null`

Not the best idea, since some OS'es have pretty small buffers used for command arguments. If the find construct above returns several thousands of results, you _might_ encounter a buffer overflow, so that the loop itself won't be processed.

Regards,
-XoF-
JJSmithCommented:

I would guess that the number of INPUTFILE_FF's found under /usr/dstage/data/Basel2/work would not blow the buffer. But from a more robust point of view I would endorse XoF comment that a find piped to a while read is much more 'economical' than a for in `find list` and therefore offers more future scalability.

Cheers
JJ

gheistCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:

split between ahoffmann http:#16499223 and root_start http:#16650372

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

gheist
EE Cleanup Volunteer
XoFCommented:
hmm, just wondering why you suggest splitting between ahoffmann and root_start, since root_start delivered no new input, just another shell variant (which btw. IMO is only the 2nd choice because of the discussed buffer issue) for my solution. So IMHO the points should be either awarded to ahoffmann only, since he provided the first working solution, or split between ahoffmann and me, cause I delivered a shorter, more efficient variant.

Kind regards,

-XoF-
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.