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
Filter data from text file b_sri Windows & DOS: Issues & Discussions 18 04-16-2008 07:41 AM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-09-2007 11:25 PM
Exporting text file data to csv l_jayakumar Shell Programming and Scripting 3 09-18-2005 08:27 PM
How to extract data from a text file negixx Shell Programming and Scripting 1 07-19-2005 06:30 PM
getting data out from a text file skotapal Shell Programming and Scripting 7 09-14-2002 08:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-17-2008
Registered User
 

Join Date: Nov 2007
Posts: 9
How to fetch data from a text file in Unix

I want to fetch passwords from a common file xxxx.txt and use it in a script.

Currently the password is hardcoded so this have to be changed so that password can be fetched from text file.....

Please reply asap..


Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 01-17-2008
Registered User
 

Join Date: Dec 2007
Posts: 14
use while read

try

while read ANYNAME
do

echo ${ANYNAME}
#each line will be stored in this variable 1 at a time
*****
done < xxxx.txt
Reply With Quote
  #3  
Old 01-17-2008
Registered User
 

Join Date: Jan 2007
Location: Boston, USA
Posts: 16
Try the "FOR Loop..."

you can use the below FOR loop.
If you have only password in the xxxx.txt, then this will help.
Otherwise you need to cut to get the value stored, into the passwd variable.

#########################
for x in `cat xxxx.txt`
do
passwd=$x
#
#your processin will come here.
#
done
#########################

Please revert if u hv any concerns.

Best Regards,
Karthikeyan.
Reply With Quote
  #4  
Old 01-18-2008
Registered User
 

Join Date: Nov 2007
Posts: 9
Unhappy please clarify

can you please tell me what exactly do u mean by

#
#your processin will come here.
#
done
#########################
Reply With Quote
  #5  
Old 01-25-2008
Registered User
 

Join Date: Jan 2007
Location: Boston, USA
Posts: 16
Thumbs up explanation

Hi

Sorry for the late reply. Was little busy with work.

#########################
for x in `cat xxxx.txt`
do
passwd=$x
#
#your processing will come here.
#
done
#########################

What are you going do after getting the password in a variable ???
thats what i meant by that sentence.

Pls let me know your exact requirement if this doesn't answer you....:b
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:36 AM.


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

Content Relevant URLs by vBSEO 3.2.0