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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-17-2008
shikhakaul shikhakaul is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 11
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
  #2 (permalink)  
Old 01-17-2008
prash184u prash184u is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 23
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
  #3 (permalink)  
Old 01-17-2008
Karthikeyan_113 Karthikeyan_113 is offline
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.
  #4 (permalink)  
Old 01-18-2008
shikhakaul shikhakaul is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 11
Unhappy please clarify

can you please tell me what exactly do u mean by

#
#your processin will come here.
#
done
#########################
  #5 (permalink)  
Old 01-25-2008
Karthikeyan_113 Karthikeyan_113 is offline
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
Sponsored Links
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 12:15 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