Can anyone solve this awk issue ?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can anyone solve this awk issue ?
# 1  
Old 11-26-2008
Java Can anyone solve this awk issue ?

awk -F^ '{ if (($1 != "X") && ($5 != "3")) || if (($1 != "S") && ($5 != "2")) print $0}' abc> xyz

The above command returns this error

awk: syntax error near line 1
awk: illegal statement near line 1


I am newbie to awk, Any awk intelligence involved in correcting this issue is highly appreciated.

Thanks in advance.
# 2  
Old 11-26-2008
Remove the second if in your awk command.

Regards
# 3  
Old 11-26-2008
Suggested usage:

awk -F^ '{ if ( (($1 != "X") && ($5 != "3")) || (($1 != "S") && ($5 != "2")) ) print $0}' abc> xyz


Regards,
Vinod.



Quote:
Originally Posted by karthickrn
awk -F^ '{ if (($1 != "X") && ($5 != "3")) || if (($1 != "S") && ($5 != "2")) print $0}' abc> xyz

The above command returns this error

awk: syntax error near line 1
awk: illegal statement near line 1


I am newbie to awk, Any awk intelligence involved in correcting this issue is highly appreciated.

Thanks in advance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to solve hang issue in script?

i have one function block in the beginning of my script and there are some commands inside that function which will perform some operations. And i am invoking that function from my main script by passing some values. Sometimes it is hanging in the middle for some value. For example: For 1st... (3 Replies)
Discussion started by: thomasraj87
3 Replies

2. Programming

Removed /root/.cabal by mistake - how to solve this issue?

I have mistakenly removed /root/.cabal/ from my root directoty and when I tried to reinstall it I get this output: faiz:~$ sudo cabal install pandoc --reinstall Resolving dependencies... In order, the following will be installed: pandoc-1.14.0.4 (reinstall) Warning: Note that reinstalls are... (3 Replies)
Discussion started by: faizlo
3 Replies

3. Shell Programming and Scripting

Can't solve a simple SSH/scp issue.. Please help.

Disclaimer: I tried searching but wasn't able to get to the answer so please don't flame. Scenario: I have a root script that generates a file on box1 and then needs to scp it over to box2 using user1. Both boxes are running open-ssh. root@locat-host# scp /tmp/file1 user1@box2:/tmp/file1 ... (10 Replies)
Discussion started by: denissi
10 Replies

4. Shell Programming and Scripting

How to solve awk: line 1: runaway string constant error?

Hi All ! I am just trying to print bash variable in awk statement as string here is my script n=1 for file in `ls *.tk |sort -t"-" -k2n,2`; do ak=`(awk 'FNR=='$n'{print $0}' res.dat)` awk '{print "'$ak'",$0}' OFS="\t" $file n=$((n+1)) unset ak doneI am getting following error awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies

5. Shell Programming and Scripting

Request to checkVenn diagram issue solve by Unix programm

Hello Any Unix programm can help me to solve thsi issue: I have 2 venn digrams please checke the attached file for pictures of venn diagram for eg red is A yellow is B and green is C..Please see attached file for Venn diagrams In one ..... I have 3 data set A , B and C Venn diagram... (0 Replies)
Discussion started by: manigrover
0 Replies

6. Shell Programming and Scripting

Bash or awk script to solve this problem

Hi everybody! I have written some awk scripts that return me some results I need to process. At the moment I use openOffice to process them, but I am trying to find a more efficient solution using possibly a bash or awk script. I have two files, file1 is in the format: time position ... (3 Replies)
Discussion started by: Alice236
3 Replies

7. UNIX for Advanced & Expert Users

Help! SHELL or AWK script - only the masters of the forum will solve

Hello everybody! I have no experience with shell Programmer, but I need to compare 02 files. Txt and generate an output or a new file, after the comparisons. see: If the column 1 of file1 is equal to column 1 of file2, and column 3 of file2 contains the column 4 of file1, output: column1... (4 Replies)
Discussion started by: He2
4 Replies

8. Solaris

please help me solve this issue.........

Hi, I am having a Solaris 5.9 server in which an audit trail script is running every day.It is doing nothing but taking the backup of three files given below -rw-r--r-- 1 root root 1807 May 18 01:30 login_server1_17May2008 -rw-r--r-- 1 root root 0 May 18 01:30... (5 Replies)
Discussion started by: Renjesh
5 Replies

9. Solaris

Help me to solve this issue

Hi, I want to send a .tar file from one solaris 5.9 server to another server in order to make files in sync.What method i can use? (2 Replies)
Discussion started by: Renjesh
2 Replies

10. Shell Programming and Scripting

Can AWK solve it ???

Hi I have some 200 tables and I have macro which actually returns the tables columns descriptions . Say for exapmle describe('table1') will list all the columns of table one with the description. Now what I want to do is I want to write a shell script which will take tables name from a file... (1 Reply)
Discussion started by: emon
1 Replies
Login or Register to Ask a Question