Reading from list file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading from list file
# 1  
Old 05-24-2010
Reading from list file

Hi All,

I am spooling a list file from sql.

Code:
spool '$HOME/my.lst' ;
select a,b from table;
spool off;

Can anyone help me to read both the columns a and b on unix.

Regards,
Vikram

Last edited by pludi; 05-25-2010 at 03:20 AM..
# 2  
Old 05-24-2010
Code:
IFS=' '
while read a b
do
echo "a is $a"
echo "b is $b"
done < $HOME/my.lst


cheers,
Devaraj Takhellambam

Moderator's Comments:
Mod Comment pludi: Please use code tags even for short listings

Last edited by pludi; 05-25-2010 at 03:21 AM..
# 3  
Old 05-25-2010
MySQL

Tx Dev,

but still my problem is not completely solved. As you had mentioned

Code:
IFS=' '
while read a b
do
echo "a is $a"
echo "b is $b"
done < $HOME/my.lst

I m able to get the output for b..but can you please further let me know what to do if I need to take the first 5 character from a and make it a directory name.

As I m very new for unix hope u understand my terminology.

Regards,
Vikram

Last edited by pludi; 05-25-2010 at 03:21 AM..
# 4  
Old 05-25-2010
Use cut command.

Code:
IFS=' '
while read a b
do
echo "a is $a"
dirname=`echo $a | cut -c 1-5`
echo $dirname
echo "b is $b"
done < $HOME/my.lst


cheers,
Devaraj Takhellambam
# 5  
Old 05-25-2010
thanks, It works
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh Script, Reading A File, Grepping A File Contents In Another File

So I'm stumped. First... APOLOGIES... my work is offline in an office that has zero internet connectivity, as required by our client. If need be, I could print out my script attempts and retype them here. But on the off chance... here goes. I have a text file (file_source) of terms, each line... (3 Replies)
Discussion started by: Brusimm
3 Replies

2. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

3. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

4. UNIX for Dummies Questions & Answers

Reading Table name from a list of files in a Directory

Hi , I have searched through the forum but not able to find out any help :( i have a directory having lot of files which contains sql statemtns eg : file 1 contains select from table_name1 where ..................... select from table_name2 where .......... select from ... (3 Replies)
Discussion started by: Trendz
3 Replies

5. OS X (Apple)

Segmentation fault when reading out a linked list

Hey everyone, this is my first time posting, so hopefully i won't commit some kind of egregious faux pas. :) Anyways, I'm trying to create and read back a simple linked list in C++. So far, I think I've built it and filled it with 10 different arrays of characters of about 22 characters each.... (2 Replies)
Discussion started by: gravity black
2 Replies

6. Shell Programming and Scripting

Searching for Log / Bad file and Reading and writing to a flat file

Need to develop a unix shell script for the below requirement and I need your assistance: 1) search for file.log and file.bad file in a directory and read them 2) pull out "Load_Start_Time", "Data_File_Name", "Error_Type" from log file 4) concatinate each row from bad file as... (3 Replies)
Discussion started by: mlpathir
3 Replies

7. Shell Programming and Scripting

Shell Scripting Reading List

Hello Everyone, Over the last few months I have begun to expand my programing skills from windows, Java and SQL / PL-SQL programing into the wonderful world of shell scripting. With little training budget my only options for training are books, Internet and this site (BTY... (1 Reply)
Discussion started by: caddis
1 Replies

8. Shell Programming and Scripting

Reading list of files into ftp script

How can I go about getting this done? I have tried and failed with a loop before I start the session and after seeing that I am already in the ftp code block and not bash when I am trying to perform this: #FTP Information ftp_server=xx.xxx.xxx.xx ftp_user=xxxx while read line; do... (1 Reply)
Discussion started by: BkontheShell718
1 Replies

9. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies
Login or Register to Ask a Question