![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
can you please tell me what exactly do u mean by
# #your processin will come here. # done ######################### |
|
#5
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |