a system call for sed in a awk script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers a system call for sed in a awk script
# 1  
Old 05-20-2005
a system call for sed in a awk script

Hi,

this is my test file :

DELETE FROM TABLE
WHERE ID_INTERNAL = :TABLE.ID-INTERNAL, ID-INTERNAL-CRAZY
ID-INTERNAL-OPEN
ID-INTERNAL

/ID-INTERNAL/


I want all occurences of ID-INTERNAL replaced with a one, if ID-INTERNAL has and dash afer it , dont replace it example: ID-INTERNAL-CRAZY,

I'm using an awk script at the moment, but I'm having syntax errors,
especially with the system sed line ,any ideas ?

BEGIN{}
/ID-INTERNAL[^-]/ \
{
system( "sed s/" ID-INTERNAL "/" 1 "/" $file > $file.out)
}
END{}
# 2  
Old 05-20-2005
gsub("ID-INTERNAL[^-]", "1")
# 3  
Old 05-20-2005
my operating doesnt recognize "gsub"

It say syntax error I have the following:

BEGIN{}
/ID-INTERNAL[^-]/ \
{
gsub("ID-INTERNAL[^-]", "1")
}
END{}
# 4  
Old 05-20-2005
what OS are you on?

and this?
gsub("ID-INTERNAL[^-]", "1", $0)
# 5  
Old 05-20-2005
SunOs 5.9

when I add your latest change I have a syntax error.

this is what i have :

BEGIN{}
/ID-INTERNAL[^-]/ \
{
gsub("ID-INTERNAL[^-]", "1",$0)
}
END{}
# 6  
Old 05-20-2005
Quote:
Originally Posted by seaten
SunOs 5.9

when I add your latest change I have a syntax error.

this is what i have :

BEGIN{}
/ID-INTERNAL[^-]/ \
{
gsub("ID-INTERNAL[^-]", "1",$0)
}
END{}
works fine for me - no syntax errors.
make sure you don't have any control chars in your awk file.
# 7  
Old 05-20-2005
Try nawk or gawk instead of awk. My SunOS system has an old version of awk.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using sed inside system call in awk

HI , I am trying to write a code where if a file system has / at the end then replace it with null but it should not affect root file system / for example if ip is /var/opt/home/ then o/p is /var/opt/home but if ip is / then it should remain /. for this i am using below code but no success... (8 Replies)
Discussion started by: Jcpratap
8 Replies

2. Shell Programming and Scripting

awk script to call another script based on second column entry

Hi I have a text file (Input.txt) with two column entries separated by tab as given below: aaa str1 bbb str2 cccccc str3 dddd str4 eee str3 ssss str2 sdf str3 hhh str1 fff str2 ccc str3 ..... ..... ..... (1 Reply)
Discussion started by: my_Perl
1 Replies

3. Shell Programming and Scripting

Call awk script

The below awk script (loop.awk) is in the cygwin home directory. I do a cd to the directory where the Sources.txt is (where I would like the data output in), but the script does not run: echo loop | ./loop.awk loop.awk #!/bin/awk -f BEGIN {} cat Sources.txt | while read a do... (10 Replies)
Discussion started by: cmccabe
10 Replies

4. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

5. Shell Programming and Scripting

How to call the System command twice in the same perl script...

Hello experts, I have a perl script which looks for the ARGV and then loads the data as per it. Example. #Checking the server to connect if ($ARGV eq 'QA') { $ENV{"ORACLE_HOME"} = "/oracle/product/11.2.0"; $ENV{"PATH"} = "$ENV{'PATH'}:/oracle/product/11.2.0/bin"; ... (1 Reply)
Discussion started by: msrahman
1 Replies

6. Shell Programming and Scripting

System call using awk on Solaris

I'm brand new to awk and need your help. I want to be able to shut down my workstations when they become to hot (because we've lost our cooling). I found a really neat way to monitor the temperature of the system and a short, simple awk scipt to use with it: /usr/sbin/prtpicl -v -c... (2 Replies)
Discussion started by: natural
2 Replies

7. Shell Programming and Scripting

Running a script in system() call and want the script's output

Hi All, I have a script(sample.sh) displaying the output of "dd" command. Now i am using this script in system() call as, system("sh sample.sh") in an application file. I want the output of system("sh sample.sh") in the application file itself. How can i get it? Many thnaks.... (9 Replies)
Discussion started by: amio
9 Replies

8. Shell Programming and Scripting

Passing argument to system call in awk script

So, I have this script. It reads a CSV file that has a mixture of object names with IP addresses (parsing out that part I have working), and object names which have a DNS name. I want to be able to run a "dig +short" based off of the name given to me in the line of the awk script, and then deal... (6 Replies)
Discussion started by: mikesimone
6 Replies

9. Shell Programming and Scripting

How to call last 14 characters with grep/sed in shell script.

Hi. This is my first post on the forums. I am trying to write a script that will parse a folder of files "oneverylongfilenamexyz.pdf" and create a .dat file named "oneverylongfilenamexyz.dat" with the first line of each .dat file saying variable="xyz" where xyz is the last 14 characters of $i... (4 Replies)
Discussion started by: attonbitusira
4 Replies

10. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies
Login or Register to Ask a Question