The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 03:02 PM
read/writte/input data in file. dorek Shell Programming and Scripting 0 06-22-2006 07:31 AM
Read the lines from the file in batch amitraorane Shell Programming and Scripting 2 01-26-2006 01:51 PM
read a file as input and pass each line to another script sajjad02 Shell Programming and Scripting 0 09-24-2004 11:13 PM
trying to read batch process but need some command help etravels Shell Programming and Scripting 1 11-19-2003 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-16-2005
kinmak kinmak is offline
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!
  #2 (permalink)  
Old 02-16-2005
RTM's Avatar
RTM RTM is offline Forum Advisor  
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.
  #3 (permalink)  
Old 02-16-2005
nir_s nir_s is offline
Registered User
  
 

Join Date: Jun 2004
Posts: 148
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
  #4 (permalink)  
Old 02-16-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
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 03:38 PM.. Reason: Update UUOC URL
  #5 (permalink)  
Old 02-16-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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.
  #6 (permalink)  
Old 02-16-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

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

what about

Code:

chmod 777 `cat input.txt`
  #7 (permalink)  
Old 02-16-2005
kinmak kinmak is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0