Awk and read bailing out


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk and read bailing out
# 1  
Old 06-15-2010
Awk and read bailing out

Hi All,

Can some body help me in this to work
Code:
#!/bin/ksh

    nof=`wc -l outFile_R.out | sed -e 's/[a-zA-Z_. ]*//g' `
    no_of_lines=`expr $nof - 0`
    z=1
    while [[ $z -le $no_of_lines ]]
    do
    cat outFile_R.out | awk -v I="$z" 'NR==I { print $0 }' | read from_date to_date id
    echo "executing $from_date $to_date $id"
    z=$((z + 1))
    done

output required if no_of_lines = 2

executing 2010-01-01 2010-01-31 1
executing 2010-01-01 2010-01-31 2

---------- Post updated at 02:14 PM ---------- Previous update was at 02:09 PM ----------

got it working using nawk Smilie
# 2  
Old 06-15-2010
Hi sol_nov,

I noticed it may be possible to further simplify your script to something like this.
Code:
while read from_date to_date id
do
  echo "executing $from_date $to_date $id"
done < outFile_R.out

Perhaps that could be of use to you...
# 3  
Old 06-15-2010
Quote:
Originally Posted by sol_nov
got it working using nawk Smilie
Smilie

On Solaris it's generally better to use /usr/xpg4/bin/awk or nawk and not /usr/bin/awk
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk read RS

I need to know if there is a way to use the while read command from a awk record. The record has 3 or 4 lines and I need the line to be all of the record instead of just each line of it. nawk 'BEGIN {RS="!"} /atm pvc/ {print $0}' router.list | while read line do VP=`echo "$line" | egrep "atm... (7 Replies)
Discussion started by: numele
7 Replies

2. Answers to Frequently Asked Questions

awk: bailing out

If you see this: awk: syntax error near line 1 awk: bailing out near line 1 Chances are you are working on Solaris and you are using standard awk. If so, you need to use /usr/xpg4/bin/awk instead, which is POSIX awk (or nawk if that is not available). (1 Reply)
Discussion started by: Scrutinizer
1 Replies

3. Shell Programming and Scripting

How to use awk with while read line

Hi All, Content of mydatafile- Name Age -------------- --------------- Raju P 20 years Hari 25 years Priya S 30 years I need output like- The age of Raju P is 20 years The age of Hari is 25 years The age of Priya S is... (3 Replies)
Discussion started by: NARESH1302
3 Replies

4. Shell Programming and Scripting

AWK syntax /bailing script error when executing in UNIX

Hi I am trying to execute the following awk script in unix but getting the following error awk: syntax error near line 1 awk: bailing out near line 1 for i in `cat search` do grep -i -l $i *.sas | awk -v token=$i '{print token "\t" $0}' done Please let me know what could be the... (4 Replies)
Discussion started by: nandugo1
4 Replies

5. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

6. UNIX for Dummies Questions & Answers

Using Awk within awk to read all files in directory

I am wondering if anyone has any idea how to use an awk within awk to read files and find a match which adds to count. Say I am searching how many times the word crap appears in each files within a directory. How would i do that from the command prompt ... thanks (6 Replies)
Discussion started by: flevongo
6 Replies

7. Shell Programming and Scripting

Using awk to read a field

I am trying to output the total number of records that have name and address within there specific fields i.e. $6 (surname) $9 (address). The file that redirects in is a csv file. The code is wrong somewhere as i have another awk similar to this that reads in the same file and that works... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

8. Shell Programming and Scripting

How to re-read a file in AWK

Hi , i am having some problem with re-reading the same file in AWK. here is the scenario. function 1 { some_string > " file1 " # i have redirected output to file1. ........... ........ } Now in function 2 { ... (1 Reply)
Discussion started by: madhaviece
1 Replies

9. Shell Programming and Scripting

Help with awk - read from file

Hi, I've got a file like the following: Starting to process segment 0 (and symmetry related segments) Number of (cancelled) singularities: 0 Number of (cancelled) negative numerators: 0 Segment 0: 5.49secs Starting to process segment 1 (and symmetry related segments) Number of... (7 Replies)
Discussion started by: giorgos193
7 Replies

10. Shell Programming and Scripting

-awk: bailing out near line 1

Hi I'm using cygwin and the script below works just fine under cygwin.. when i upload it on a unix server the script fails with the following errors -awk: syntax error near line 1 -awk: bailing out near line 1 any ideas why? thanx awk '($2 ~ /*/) { if ($4 < 40){ print... (3 Replies)
Discussion started by: kion
3 Replies
Login or Register to Ask a Question