Sponsored Content
Full Discussion: Nawk sub not substituting
Top Forums Shell Programming and Scripting Nawk sub not substituting Post 302905730 by smenago on Friday 13th of June 2014 11:27:26 AM
Old 06-13-2014
Thanks for the input. I reassigned correctly and tried to alter the command based on the interpretation of the gsub.

I simplified it to the below.
Code:
nawk -F / -vz=Peoccam.20140613 ' { gsub("Peoccam", z,$5) ; print $0} '

However, when I execute the below the return gives the path without the foward slashes -
Code:
smenago@sftp02$ bash -x test_app
++ /usr/local/bin/date +%Y%m%d
+ ydate=20140613
+ echo 20140613
20140613
+ test_ca=/home/mdadmin/test_ca
++ cat /home/mdadmin/test_ca
+ for i in '`cat ${test_ca}`'
+ [[ /pub/data/cana/Peoccam == *cana* ]]
++ /usr/bin/nawk -F/ -v dt=20140613 '{ print $5 "." dt }' /home/mdadmin/test_ca
+ new_f=Peoccam.20140613
+ echo Peoccam.20140613
Peoccam.20140613
+ mv /pub/data/cana/Peoccam /pub/data/cana/Peoccam.20140613
mv: cannot access /pub/data/cana/Peoccam
+ echo /pub/data/cana/Peoccam
/pub/data/cana/Peoccam
+ nawk -F / -vz=Peoccam.20140613 ' { gsub("Peoccam", z,$5) ; print $0} ' /home/mdadmin/test_ca
 pub data cana 

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

substituting shell variables

I have a script run_batch.sh as below :- PAR_VALIDATION=val_siconf PAR_RUN_LEVEL=1 PAR_EXCLUSIVE_RUN_YN=Y DATABASE_USER="/@"$TWO_TASK sqlplus -s $DATABASE_USER |& print -p -- 'set feed off pause off pages 0 head off veri off line 500' print -p -- 'set term off time off... (1 Reply)
Discussion started by: suds19
1 Replies

2. Shell Programming and Scripting

Substituting with value of variable in Sed

Hi, I have a program in which i have to substitute a TAG in a file with the value of a variable. Code Snippet: ---------------- myvar=1234 sed 's/_TAG_/$myvar/' infile outfile When I run this command, the _TAG_ in the "infile" is substituted with "$myvar" but NOT the value "1234"... (1 Reply)
Discussion started by: jyotipg
1 Replies

3. Shell Programming and Scripting

substituting

Hello please how can i change this infrormation within a file dynamically without using vi " || $6 ~ /^229*/ " the * means any number within the file has this content : cat lec|awk -F '|' 'length($6) >= 12 || length($6) <= 10' |awk -F '|' '$6 ~ /^24/ || $6 ~ /^22924/ &&$7 ~... (1 Reply)
Discussion started by: neyo
1 Replies

4. Shell Programming and Scripting

how to access values of awk/nawk variables outside the awk/nawk block?

i'm new to shell scripting and have a problem please help me in the script i have a nawk block which has a variable count nawk{ . . . count=count+1 print count } now i want to access the value of the count variable outside the awk block,like.. s=`expr count / m` (m is... (5 Replies)
Discussion started by: saniya
5 Replies

5. Programming

substituting one string for another

I have a Linux C program I'm writing that has one section where, within a large string, I need to substitute a smaller string for another, and those probably won't be the same size. For instance, if I have a string: "Nowisthetimeforallgoodmen" and I want to substitute 'most' for 'all' the... (2 Replies)
Discussion started by: cleopard
2 Replies

6. Shell Programming and Scripting

Substituting Characters using SED

Can SED be used to substitute a character (y) with a character (Y) in a specified field? File has 12000 : delimeted rows as; HHC 1 BDE:Lastname, Firstname MI:firstname.mi.lastname@mil:SGT HHC 2 BDE:Lastname, Firstname MI:Firstname.MI.Lastname@mil:SGT I wish to replace the capital letters... (6 Replies)
Discussion started by: altamaha
6 Replies

7. Shell Programming and Scripting

Substituting the values

Hi Gurus this is working finee with tested values #!/bin/ksh V_DATE="2007-11-30" V_ID=789 V_NAME="john_${V_ID}_has_${V_DATE}_s" FILE_NAME=`echo ${V_NAME}` echo ${FILE_NAME} Buttt the problem is the first two values will come dynamically and the file will looks like... (2 Replies)
Discussion started by: SeenuGuddu
2 Replies

8. UNIX for Dummies Questions & Answers

substituting variable value in AWK

Hi All, my requirement is as below. I need to replace a value in a particular column with a substitution variable(date value) and modified value of the current column value in the same position. for ex. i have a record like 02;aaaa;bbbbb;cccccc;dddddd;123456789;hhhhh;12hs;asdf ;... (3 Replies)
Discussion started by: ganesh_248
3 Replies

9. UNIX for Dummies Questions & Answers

Variable is not substituting values

Hi All, OS HPUX 11.11 I am using following script to take controlfile backup. I have used SID variable to hold "ffin1" value, which I again subsitute in "'/db/ffin1/home/oraffin1/$SID_$wdate.ctl'" command. Well, after running this, SID variable does not subsittue it's value, while wdate... (6 Replies)
Discussion started by: alok.behria
6 Replies

10. Shell Programming and Scripting

Nawk Problem - nawk out of space in tostring on

Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
Discussion started by: Abhiraj Singh
12 Replies
ggAddObserver(3)							GGI							  ggAddObserver(3)

NAME
ggAddObserver, ggDelObserver, ggNotifyObservers, ggClearPublisher - Simple observer framework SYNOPSIS
#include <ggi/gg.h> typedef int (ggfunc_observer_update)(void *arg, int flag, void *data); struct gg_observer { ggfunc_observer_update *update; void *arg; GG_LIST_ENTRY(gg_observer) _others; }; struct gg_publisher { GG_LIST_HEAD(gg_observer_list, gg_observer) observers; }; #define INIT_PUBLISHER(pub) GG_LIST_INIT(&((pub)->observers)) struct gg_observer * ggAddObserver(struct gg_publisher *, ggfunc_observer_update *, void *); void ggDelObserver(struct gg_observer *); void ggNotifyObservers(struct gg_publisher *, int, void *); void ggClearPublisher(struct gg_publisher *); DESCRIPTION
The observer pattern is very useful and commonly found in many software packages, even if not explicitly called that way. The problem is that every different software will often use a particular implementation of this pattern, depending on a specific use-case. So usually everybody prefers to roll its own. LibGG observers are defined as part of the forth-coming api infrastructure, as light-weight cooperation model between libraries. The model is very simple: struct gg_publisher defines a channel on which observers can be registered. An observer is simply an opaque value and a callback receiving that value as first argument, a flag, and an opaque channel-specific message. The idea is that if you known the observable you're listen- ing on, you know the semantics behind the flag and message. When the observable is triggered, all observers' callbacks will be fired. ggAddObserver registers a new observer on a publisher. ggDelObserver unregisters the given observer from its publisher and frees it. ggNotifyObservers triggers all observers update functions for that publisher. The flag and message will be given to the observers' update callbacks. An observer *must not* call ggDelObserver on itself in the update function to unregister. Instead it must return a non-zero value. ggClearPublisher frees all observers registered on the publisher. If at least one is left, then there is probably a logical error in the observer code, since it must already have been notified some- how of the publisher going down, and unregistered all callbacks before. RETURN VALUES
ggAddObserver returns a newly constructed observer hook. Normally, the caller will keep a reference to it to call if he needs to call ggDe- lObserver later. EXAMPLE
#include <ggi/gg.h> #include <stdio.h> int update(void* o, int f, void *d) { printf("update called for observer %p, flag=%i, data=%p ", o, f ,d); if (o == 1) { return 1; /* unregister */ } return 0; } int main() { struct gg_publisher pub; struct gg_observer *o1, *o2; INIT_PUBLISHER(&pub); o1 = ggAddObserver(&pub, update, (void*)1); o2 = ggAddObserver(&pub, update, (void*)2); ggNotifyObservers(&pub, 0, NULL); ggNotifyObservers(&pub, 1, NULL); ggClearPublisher(&pub); return 0; } libgg-1.0.x 2005-08-26 ggAddObserver(3)
All times are GMT -4. The time now is 07:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy