shell script urgent help

I have the following command

find /dir/directory1/DEV.pdf -type f -exec cksum {} \; >> file.txt 2>&1

I want to read all file paths in bold from input.txt

content of input.txt
/dir/directory1/DEV.pdf
/dir/directory1/DEV2.pdf
/dir/directory1/DEV.3pdf
/dir/directory1/DEV4.pdf
/dir/directory1/DEV5.pdf
/dir/directory1/DEV6.pdf

Following command is not working for me

find `cat input.txt` -type f -exec cksum {} \; >> file.txt 2>&1

Is there any alternative ...? I am getting "No such file or directory"
LVL 5
CalmSoulAsked:
Who is Participating?
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.

woolmilkporcCommented:
Did you really use backticks around the cat command as posted?

Please try using $(  ) instead of ` `:

find $(cat input.txt) -type f -exec cksum {} \; >> file.txt 2>&1

If still no luck please make sure that all the directories listed in input.txt really exist:

xargs -I{} ls -d {} >/dev/null < input.txt

Any "not found" messages?
0
CalmSoulAuthor Commented:
I think problem is NAS path in input file ... It's a mount point path...
0
woolmilkporcCommented:
If correctly mounted NAS directories shouldn't cause any problem.

To silently skip missing directories use

find $(cat input.txt) -type f -exec cksum {} \; >> file.txt 2>/dev/null
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Gerwin Jansen, EE MVETopic Advisor Commented:
Can you try this instead:

for a in $(cat input.txt)
do
  echo chksum "$a" >> file.txt 2>&1
done;

Open in new window



If you see a list of chksum commands with filenames then remove the echo.
0
savoneCommented:
The problem is your input file is a list of files and their directories.  The find command is used to FIND files, you already know where they are since you have their path and names in the file.

Just run the following to get the checksum for each file:

for i in `cat input.txt`; do cksum $i; done

Open in new window

0
woolmilkporcCommented:
Shouldn't make a difference.
"find" can accept a path/filename combo as its path parameter.
That's rather uncommon and expensive, but it works.

On the other hand, Linux' cksum does not work against directories (Unix' cksum generally does).

So using "find" allows running cksum against a mix of pure paths and path/filename combos in input.txt without errors (if all elements in input.txt exist, that is).

If, and only if, input.txt contains just filenames you can simply use

cksum $(<input.txt) >> file.txt 2>&1

or, for a huge number of entries listed in input.txt:

xargs cksum < input.txt >> file.txt 2>&1
0

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
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
Shell Scripting

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.