read input file for batch job

hi all,

I am a newbie in unix shell script. May I know how to write a bacth job to
read a list of files afrom the inout file and do the chmod ? Thanks.
i.e.
inside input.txt

a.txt
b.txt
c.txt

and I want to write a batch job to read the input .txt and do the chmod 755 for all 3 files in the input.txt

thx in advance!

I don't understand - you stated in your other post about the exact same thing that you were going to use if statements - yet, you post the exact same question with no code. Either post the code you have been busy working on and questions about problems with it, or use the suggestions from the replies in your other post. Thanks.

Hi kinmak,

If you want to grant full permissions mode to the files (777),your shell script should be as the following:

#! /bin/ksh
cat input.txt | while read line
do
chmod 777 $line >/dev/null 2>&1
done

Good luck!

Nir

UUOC

while read line
do
  chmod 777 "${line}" >/dev/null 2>&1
done < input.txt

kinmak, please read our rules and note in particular:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

I removed your duplicate post from that other thread.

what about


chmod 777 `cat input.txt`

Hi Vgersh99 ,
Thansk for yourr reply...
may I know what does this part of command mean >/dev/null 2>&1 ?

thx

>/dev/null
redirect [implicitely know] fileDescriptor '1' [aka stdout] to device '/dev/null'

2>&1
map fileDescriptor '2' to fileDescriptor 1 [fileDescriptor '2' aka 'stderr']

The result of the redirection is that both stdout AND stderr will be directed to the file [/dev/null] - discarded.

Vgersh99,yhx for your prompt reply..
However, if I don't need any output, can I simply
type
chmod 777 "${line}" in the batch file?

if carefully read the explanation, that's exactly what the script will do.

Moderator: Any chance you could change the link to point to the proper location Partmaps.org -- you will notice that the 302 at netsonic.fi redirects to the same location (the redirector will go away, maybe soon).

There's another mention at Some Sites Recommended by Our Users -- maybe you could change that too.

bhargav's answer is the best (apart from the silly chmod 777, when 755 was specifically what was asked for in the first place) if you know the list of files is smallish; otherwise, you'll bump into the ARG_MAX limit. This is also described on the Awards page.

I will split this thread later to create a thread about the UUOC links which will be moved to a non-public forum. I want to document the links that may need a review:
Some Sites Recommended by Our Users is currently pointing to http://laku19.adsl.netsonic.fi/era/unix/award.html Done

Also:
this thread -> http://laku19.adsl.netsonic.fi/~era/unix/award.html Done
this thread -> this post -> http://laku19.adsl.netsonic.fi/era/unix/award.html Done

this thread -> UUOC -> http://www.ling.helsinki.fi/~reriksso/unix/award.html
this thread -> http://www.ling.helsinki.fi/~reriksso/unix/award.html Done

http://www.ling.helsinki.fi/~reriksso/unix/award.html also redirects to Partmaps.org
I changed our direct link to http://www.ling.helsinki.fi/~reriksso/unix/award.html but I will leave the link to http://www.catb.org/~esr/jargon/html/U/UUOC.htm alone

I'm not sure if I should change this thread since tries to use html to link to http://www.ling.helsinki.fi/~reriksso/unix/award.html which used to work but we disabled html a few years ago.

Thanks for your fixes (and sorry for taking so long to respond). Do you think you could revisit this, still? Looks like the link in this particular thread is not correctly formatted (can't remember if it always was broken) and also the first one in your list still seems to link to the old location.

Thanks again.

Ok I fixed the link in this thread and the link in the first thread on my list.

Many thanks