11-30-2008
Only one particular occurence needs to be substituted !!!
In a file, field separetor in line is irregular number of spaces, so I canot use field in sub function to get my charecter replaced with empty space. I would like to substitute only one perticular charecter with space at perticular posiotn, so I canot use perticular character as that may occur before the position to be repalced. I have written the code as below but passing (/substr($0,39,1)/ to sub function is wrong. Plz suggest any alternatives for below code.
awk '{ if(substr($0,39,1)=="N") { sub(/substr($0,39,1)/," ",$0); printf "%-517s", $0" ABCD ";} }' < inputfile >
Last edited by vaka; 12-01-2008 at 02:28 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
This is the format of the file that i have
StartDate:10/01/06
EndDate :10/02/06
Cno Ccode
1 10
2 11
StartDate:10/03/06
EndDate :10/04/06
Cno Ccode
2 13
4 12
StartDate:10/01/06
EndDate :10/02/06 (5 Replies)
Discussion started by: kkm_job
5 Replies
2. UNIX for Dummies Questions & Answers
Hi ,
supoose i have a file in which a word is repeated so many times.
I just want the firts occurence of that word through grep and it should not go to the next one means get the first occurence and stop there.
Suggest me some solutions.
Thanks
Namish (10 Replies)
Discussion started by: namishtiwari
10 Replies
3. Shell Programming and Scripting
I try to run this script, however, it gives an exception in line 3. How do I do an assignment to a substituted variable?
#!/bin/bash
name=fruit
ext_$(eval echo ${name})=apple
tmp=ext_$(eval echo ${name})
if ]; then
echo "apple"
elif ]; then
echo "orange"
fi
echo ${!tmp}
Error... (2 Replies)
Discussion started by: angelokh
2 Replies
4. Programming
Is there any way to produce a code with all use dmacro to be substituted up to 'ready for compilation' condition?
Some macro are build up and it is hard to replace all them up to final code by hand.
I need to see the final line after all macro been applied by preprocessor.
How that could be... (5 Replies)
Discussion started by: alex_5161
5 Replies
5. Shell Programming and Scripting
I'm not getting the syntax correct to change a line only on the first occurrence:
I've tried to change only the first match and I've tried to change the from the second match forward
sed 's/<B>PT#/<tr><td class=\"pt1\" width=\"40%\"><B>pt#/1' $file > tmpfile.html
sed ... (0 Replies)
Discussion started by: dba_frog
0 Replies
6. UNIX for Dummies Questions & Answers
Hi there,
how can i print the first pattern occurrence in a .log file?
I want to print the filename of the first 17262?
I tried but all I can do is print all the lines with the number 17262?
I tried using awk and sed but nothing!:wall:
I just want filename!
Here´s an example:
17259... (3 Replies)
Discussion started by: BMatter
3 Replies
7. Shell Programming and Scripting
Dear all,
I have data like below and i need to add coloumn before the COUNT field to see the Percentage out of all COUNT field value for respective raw.
=============================================
COUNT CODE sConnType tConnType... (6 Replies)
Discussion started by: Iroshan
6 Replies
8. Shell Programming and Scripting
I have a file
# cat asasas
AAAAAA
11
22
33
44
BBBBB
NILNILNIL
AAAAAA
22
33
44
55
66
77
88
BBBBB
NILNILNIL (2 Replies)
Discussion started by: anil510
2 Replies
9. UNIX for Advanced & Expert Users
I have an output file which gives me the timely status of a server.
Sample file:
March 11 2014
21:10, 1, 2, 3, 4, 5, 6, 7, 8, 9, x, y, z...
21:05, 1, 2, 3, 4, 5, 6, 7, 8, 9, x, y, z...
21:00, 1, 2, 3, 4,... (3 Replies)
Discussion started by: rpm120
3 Replies
10. Shell Programming and Scripting
Hi all,
I started playing around with Python (2.6.6) trying to parse a file. No matter what I tried so far I am not able to print only the lines/group/backreference that have been affected by the substitution. Instead I get also the other lines too
File to parse:
some more text
... (2 Replies)
Discussion started by: zaxxon
2 Replies
INSTR(3) MBK UTILITY FUNCTIONS INSTR(3)
NAME
instr - find an occurence of a string in a string, starting at a specified character.
ORIGIN
This software belongs to the ALLIANCE CAD SYSTEM developed by the ASIM team at LIP6 laboratory of Universite Pierre et Marie CURIE, in
Paris, France.
Web : http://asim.lip6.fr/recherche/alliance/
E-mail : alliance-users@asim.lip6.fr
SYNOPSYS
#include "mut.h"
char *instr(s, find, from)
char *s, *find, from;
PARAMETERS
s Pointer to the string to be searched for the pattern
find Pointer to the string to be found, the pattern
from Character to be searched backwards before searching for the pattern
DESCRIPTION
instr searches the first occurence of the string find in the string s, starting its search at the last occurence of the from character in
the string s.
If either s or find is NULL, the function returns NULL. If from is (char)0, the pattern is searched from the begining of s.
This quite exotic behaviour is useful to search the occurence of a name in a string resulting from a flatten, when only a terminal object
name is to be taken into account.
RETURN VALUES
instr return NULL either if the pattern find is not present in the searched string s, or if one at least of these two string are NULL. If
the pattern is found, a value different from NULL is returned.
EXAMPLE
#include "mut.h"
/* check for the pattern 'ck' anywhere in the string */
#define contains_ck(name)instr(name, "ck", ' ')
/* check for the pattern 'ck' in the signal name, not instance ones */
#define isclock(ptsig) instr(getsigname(ptsig), "ck", SEPAR)
SEE ALSO
mbk(1), isvdd(3), isvss(3).
BUG REPORT
This tool is under development at the ASIM department of the LIP6 laboratory.
We need your feedback to improve documentation and tools.
ASIM
/LIP6 October 1, 1997 INSTR(3)