Visit Our UNIX and Linux User Community


nawk: illegal statement at source line 1


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting nawk: illegal statement at source line 1
# 1  
Old 09-03-2009
nawk: illegal statement at source line 1

Hello Everyone,

I don't know what is wrong with this:

Quote:
$ps -ef|grep java > processup.txt
$nawk '$0 !~ /mytomcat/{startup.sh}' processup.txt
nawk: syntax error at source line 1
context is
$0 !~ >>> /mytomcat/{startup. <<< sh}
nawk: illegal statement at source line 1
Is it that nawk cannot run a ".sh" script or is it not treating "." as a literal. If so how to make "." be treated as a literal in "nawk" statemnts?

Thanks in Advance
# 2  
Old 09-03-2009
Quote:
Originally Posted by bhaire

Please put code, data and sample runs inside [code] tags, not [quote] tags.
Quote:
Is it that nawk cannot run a ".sh" script

Right. Only awk syntax can be used in an awk script.

To call a shell command, use the system() function.
# 3  
Old 09-04-2009
Thank you!

Previous Thread | Next Thread
Test Your Knowledge in Computers #494
Difficulty: Easy
A block of code is a section of code that has been logically grouped together.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a String after a text in a Line (using nawk)

Hello I need to add a String after a text in a line. The Unix file is huge and I think nawk would be quick. Current: -name FILTER -node 60265 -cob 31/01/2013 -risktype + -change 1 -filter ALL_NODES -toponly -warnings OFF -delimiter "|" -noheader -select... (4 Replies)
Discussion started by: filter
4 Replies

2. Shell Programming and Scripting

Read: line 6: illegal option -e

For some reason read -e isn't working in my script. I need a directory as input from a user and I'd like for them to be able to use tab complete which is why I'm using -e. When the script is run, I get: read: line 6: illegal option -e In order to just figure out what is going on with the -e... (4 Replies)
Discussion started by: orangeSunshine
4 Replies

3. Shell Programming and Scripting

Help with finding last line of file: if statement depending on that line.

Good morning, My first time actually posting in this forum, though I have used this forum to help with numerous projects. I am trying to figure out why my if statement does not work. I have a file where a line is inputted every 15 seconds. I want this if statement to check what the last line... (3 Replies)
Discussion started by: Shanrunt
3 Replies

4. Shell Programming and Scripting

nawk and line number

Hi I am using the following "nawk" statement to get 22 lines after the pattern I have specified as an argument: $ NUM=3461 $ nawk -v a=$NUM '$0 ~ ("\\") {c=22}c&&c--' myfile The "nawk" statement works fine. But I also need to get line numbers as a part of the output. Is there a way to... (2 Replies)
Discussion started by: aoussenko
2 Replies

5. Shell Programming and Scripting

ksh/nawk help with if statement to choose between 2 files

Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be... (3 Replies)
Discussion started by: ther2000
3 Replies

6. AIX

can't parse this nawk statement

hi all i have the following portion in an xml file: </n:AOMessage> <?xml version="1.0" encoding="UTF-8"?> <n:AOMessage xmlns:n="urn:ao:hs:update:shell" xmlns:bo="urn:ao:hs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ao:hs:update:shell... (0 Replies)
Discussion started by: chipahoys
0 Replies

7. UNIX for Dummies Questions & Answers

nawk: syntax error at source line 11

Hi, I executing a awk in a shell script. A part of AWK is: nawk -F"" -v fichero=${DIRECTORIO_PARAMETROS}/${FICHERO_CONFIGURACION_CHEQUEOS} -v sistema=${SISTEMA_SEDRA} -v fichero_no_validos="No_validos_CAMPO_TIPO_${SIST}.dat" 'BEGIN{ if ( fichero != "") { ... (4 Replies)
Discussion started by: pepeli30
4 Replies

8. Shell Programming and Scripting

Illegal Statement at source line 2

Hello I'm pretty new to Shell Programming and I'm trying to write a script to display the out of a file displaying licence-use for an application. I've piped the output of my licence-use query to a file. On this file I am trying to run the following awk file, but I keep getting the error: ... (6 Replies)
Discussion started by: Glyn_Mo
6 Replies

9. Shell Programming and Scripting

Need to remove first character from every third line (or revised nawk).

Here's the data I'm starting with (example output of two combined queries, filesize: 284k) 3000877|555-55-1111|2|7/30/2008|TEST|P.O. BOX 1111|PALM DESERT|CA|92211||5555555555||||||||48|||1||1|3|||2|||||||||||||1|3||2|2... (6 Replies)
Discussion started by: VPREATR
6 Replies

10. Shell Programming and Scripting

I can't seem to pass variables properly into a nawk statement

Ok, So up front I'm going to say that I'm a very elementary scripter, and I tend to use tools I don't fully understand, but I shotgun at something until I can get it to work...that said, I can't for the life of me understand why I can't get this to go down the way I want it to. The goal: -to... (6 Replies)
Discussion started by: DeCoTwc
6 Replies

Featured Tech Videos