Using "while" to read columns in a file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using "while" to read columns in a file
# 1  
Old 10-03-2013
Using "while" to read columns in a file


i am using while to read 4 colums from a file.
but the while loop exits after reading 1st column.

please let me know, how to reach till end of the file.


birdiex1:/home/s/sandeepk/scripts> vi /tmp/gleod_time
"/tmp/gleod_time" [New file]
03_upd_stat_tbl_birdiex1                03_upd_stat_tbl_beauty                  03_upd_stat_tbl_gaston                  03_upd_stat_tbl_belle
03_run_upd_hst_beta_birdiex1            03_run_upd_hst_beta_beauty              03_run_upd_hst_beta_gaston              03_run_upd_hst_beta_belle
03_run_upd_tsc_nzf_birdiex1             03_run_upd_tsc_nzf_beauty               03_run_upd_tsc_nzf_gaston               03_run_upd_tsc_nzf_belle
03_run_upd_tsc_sy_birdiex1              03_run_upd_tsc_sy_beauty                03_run_upd_tsc_sy_gaston                03_run_upd_tsc_sy_belle
03_run_upd_tsc_so_birdiex1              03_run_upd_tsc_so_beauty                03_run_upd_tsc_so_gaston                03_run_upd_tsc_so_belle
03_run_upd_tsc_jgb_birdiex1             03_run_upd_tsc_jgb_beauty               03_run_upd_tsc_jgb_gaston               03_run_upd_tsc_jgb_belle
03_run_upd_tsc_sh_birdiex1              03_run_upd_tsc_sh_beauty                03_run_upd_tsc_sh_gaston                03_run_upd_tsc_sh_belle
03_run_upd_tsc_ph_birdiex1              03_run_upd_tsc_ph_beauty                03_run_upd_tsc_ph_gaston                03_run_upd_tsc_ph_belle
03_run_rollout-tsc-sz_birdiex1          03_run_rollout-tsc-sz_beauty            03_run_rollout-tsc-sz_gaston            03_run_rollout-tsc-sz_belle


while read col1_birdiex1 col2_beauty col3_gaston col4_belle
jobhist act $col1_birdiex1|tail -1"
ssh beauty ". .bash_profile > /dev/null 2>&1; jobhist act $col2_beauty|tail -1"
ssh beauty ". .bash_profile > /dev/null 2>&1; jobhist act $col3_gaston|tail -1"
ssh belle ". .bash_profile > /dev/null 2>&1; jobhist act $col4_belle|tail -1"
echo " "
done < /tmp/gleod_time


it comes out of loop after 1st line

/scripts> while read col1_birdiex1 col2_beauty col3_gaston col4_belle; do jobhist act $col1_birdiex1; ssh beauty ". .bash_profile > /dev/null 2>&1; jobhist act $col2_beauty|tail -1"; ssh beauty ". .bash_profile > /dev/null 2>&1; jobhist act $col3_gaston|tail -1"; ssh belle ". .bash_profile > /dev/null 2>&1; jobhist act $col4_belle|tail -1"; echo " "; done < /tmp/gleod_time

|        JOB                   |     SCHEDULE    |       LAST      |       LAST     |  JOB |
|                              |-----------------|                 |                | DURAT|
|        NAME                  |ind|    hh:mm    |       START     |       END      | (min)|
03_upd_stat_tbl_birdiex1        b   07:00          08:30  09/28/13   08:51  09/28/13  20.3
03_upd_stat_tbl_beauty          b   07:00          07:25  09/28/13   07:41  09/28/13  15.2
03_upd_stat_tbl_gaston          b   07:00          08:40  09/28/13   08:57  09/28/13  16.9
03_upd_stat_tbl_belle           b   07:00          11:46  09/28/13   12:00  09/28/13  14.6


This User Gave Thanks to sdosanjh For This Post:
# 2  
Old 10-03-2013
ssh sucks from stdin (i.e. the loop's input).
ssh -n ...

This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 10-03-2013
@MadeInGermany... It worked
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

How to delete a columns of a CSV file which has cell values with a string enclosed in " , "?

Hi How can I delete a columns from a CSV file which has comma separated value with a string enclosed in double quotes or square bracket and a comma in between? I have a csv file with below format. Template,Target Server,Target Component,Rule Group,Rule,Rule Reference Number,Rule... (7 Replies)
Discussion started by: Litu19
7 Replies

4. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; (3 Replies)
Discussion started by: lewk
3 Replies

5. UNIX for Dummies Questions & Answers

replace "," with "." only in specific columns of a file?

Hi all, I have this text file containing 9 columns separated by space. The 8th columns contains the numbers. C1 C2 C3 C4 C5 C6 C7 C8 C9 er rt yt gh iu nk il 0.07 xs yt lr ty bg iu zk nh 0,0005 lt ...etc. I want to replace the comma with full stop only in 8th coloumn. the output... (8 Replies)
Discussion started by: Unilearn
8 Replies

6. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

defining a variable using multiple "entries/columns" within a line using read

Hello All, I am trying to figure out how to use the read command. I have a txt file that has rows looking something like this: 1 2 3 4 5 6 7 8 9 where each number represents an entry of various characters deliminated by tabs. My goal is to set entries 2-7 as a variable/string that I... (3 Replies)
Discussion started by: Torinator
3 Replies

9. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

10. Shell Programming and Scripting

how to request a "read" or "delivered" receipt for mails

Dears, I've written a script which allows me to send mails in different formats with different attaches. Now I still want to add a feature to this script. My users would like to be able to receive a "read" or "delivered" receipt for their mails. The script send mails on behalve of an specific... (1 Reply)
Discussion started by: plelie2
1 Replies
Login or Register to Ask a Question