The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ls while read loop - internal read picking up wrong input dkieran Shell Programming and Scripting 2 05-14-2007 12:02 PM
read/writte/input data in file. dorek Shell Programming and Scripting 0 06-22-2006 04:31 AM
Read the lines from the file in batch amitraorane Shell Programming and Scripting 2 01-26-2006 09:51 AM
read a file as input and pass each line to another script sajjad02 Shell Programming and Scripting 0 09-24-2004 08:13 PM
trying to read batch process but need some command help etravels Shell Programming and Scripting 1 11-19-2003 06:48 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-16-2005
Registered User
 

Join Date: Feb 2005
Posts: 17
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!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 02-16-2005
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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.
Reply With Quote
  #3 (permalink)  
Old 02-16-2005
Registered User
 

Join Date: Jun 2004
Posts: 146
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
Reply With Quote
  #4 (permalink)  
Old 02-16-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 2,999
Quote:
Originally Posted by nir_s
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

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

Last edited by Perderabo; 07-08-2007 at 12:38 PM. Reason: Update UUOC URL
Reply With Quote
  #5 (permalink)  
Old 02-16-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,355
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.
Reply With Quote
  #6 (permalink)  
Old 02-16-2005
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
Smile

what about

Code:
chmod 777 `cat input.txt`
Reply With Quote
  #7 (permalink)  
Old 02-16-2005
Registered User
 

Join Date: Feb 2005
Posts: 17
Hi Vgersh99 ,
Thansk for yourr reply...
may I know what does this part of command mean >/dev/null 2>&1 ?

thx
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0