![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Read a file line by line | VENC22 | UNIX for Dummies Questions & Answers | 4 | 10-30-2008 11:09 AM |
| read the file line by line | kittusri9 | Shell Programming and Scripting | 3 | 04-24-2008 08:26 AM |
| Read file then grep the line | mr_bold | Shell Programming and Scripting | 2 | 02-07-2008 03:33 AM |
| How to read last line of a txt file? | yongho | UNIX for Dummies Questions & Answers | 2 | 06-13-2005 01:20 PM |
| read line from file | rein | Shell Programming and Scripting | 5 | 04-15-2005 02:32 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to read from a file line by line and do stuff
I want to read from a file and then do some stuff based on the text read from each line. Basically it is a list of usernames and I need to read each user, check it exist in passwd and extract their home directory and then copy a few files to that users home directory. Then move onto the next user in the file. Is this possible ??
|
|
||||
|
Quote:
Code:
{
typeset IFS='
'
while read USER_NAME
do
USER_DIR=$(grep $USER_NAME /etc/passwd | awk -F: '{print $6}')
print $USER_DIR
done < /etc/passwd
}
|
|
||||
|
This will do
FileName='specify your file here' while read LINE do echo $LINE #do your stuff here done < $FileName |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|