We assume that you know that exactly the same thing works in awk:
to make a substitution for the first occurrence producing the output:
or:
to make a substitution for all occurrences producing the output:
This User Gave Thanks to Don Cragun For This Post:
I get a text file with 70+ columns (seperated by Tab) and about 10000 rows. The 58th Column is all numbers. But sometimes 58th columns has "/xxx=##" after the numeric data. I want to truncate this string using the script. Any Ideas...:confused: (3 Replies)
Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like...
Host cmg-iqdrw3p4
LocalForward *:9043 localhost:9043
Host cmg-iqdro3p3a
LocalForward *:10000 localhost:10000
Host cmg-iqdro3p3b
LocalForward... (2 Replies)
I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM".
I can find the line number for the beginning of the statement section with sed.
... (5 Replies)
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
(o) Checkout an auto part: should prompt the user for the name of the auto part
and borrower's name:
Name:... (2 Replies)
Hi.
I would like to have experts help on below action.
I have text files in which page nubmers exists in form like
PAGE : 1
PAGE : 2
PAGE : 3 and so on there is other text too. I would like to know is it possible to check the last occurance of Page... (6 Replies)
how can i copy a certain word from a text file then use this word to replace in another text file??
i tried to use something like:
awk '{print "Hit the",$1,"with your",$2}' /aaa/qqqq.txt > uu.txt
but i can't add an argument to point to the second file which i will replace in.
please... (8 Replies)
Hi
I am looking to rename the contents of this dir, each one with a new timestamp, interval of a second for each so it the existing format is on lhs and what I want is to rename each of these to what is on rhs..hopefully it nake sense
CDR.20060505.150006.gb CDR.20121211.191500.gb... (3 Replies)
Hallo Everyone.
I have to admit I'm shell scripting illiterate . I need to find certain strings in several text files and replace each of the string by unique & corresponding text.
I prepared a csv file with 3 columns: <filename>;<old_pattern>;<new_pattern>
... (5 Replies)
Hi,
I have a file having following content.
<sip:9376507346@97.208.31.7:51088
<sip:9907472291@97.208.31.7:51208
<sip:8103742422@97.208.31.7:51024
<sip:9579892841@97.208.31.7:51080
<sip:9370904222@97.208.31.7:51104
<sip:9327665215@97.208.31.7:51104
<sip:9098364262@97.208.31.7:51024... (2 Replies)
Discussion started by: SunilB2011
2 Replies
LEARN ABOUT PLAN9
getfields
GETFIELDS(2) System Calls Manual GETFIELDS(2)NAME
getfields, getmfields, setfields, tokenize - break a string into fields
SYNOPSIS
#include <u.h>
#include <libc.h>
int getfields(char *str, char **ptrs, int nptrs)
int getmfields(char *str, char **ptrs, int nptrs)
char* setfields(char *fielddelim)
int tokenize(char *str, char **args, int max)
DESCRIPTION
Getfields breaks the null-terminated string str into at most nptrs null-terminated fields and places pointers to the start of these fields
in the array ptrs. It returns the number of fields and terminates the list of pointers with a zero pointer. It overwrites some of the
bytes in str. If there are nptr or more fields, the list will not end with zero and the last `field' will extend to the end of the input
string and may contain delimiters.
A field is defined as a maximal sequence of characters not in a set of field delimiters. Adjacent fields are separated by exactly one
delimiter. No field follows a delimiter at the end of string. Thus a string of just two delimiter characters contains two empty fields,
and a nonempty string with no delimiters contains one field.
Getmfields is the same as getfields except that fields are separated by maximal strings of field delimiters rather than just one.
Setfields makes the field delimiters (space and tab by default) be the characters of the string fielddelim and returns a pointer to a
string of the previous delimiters.
Tokenize breaks null-terminated string str into tokens by replacing every blank or newline with a null byte. Pointers to successive non-
empty tokens are placed in args. Processing stops after max tokens are processed. Tokenize returns the number of tokens processed. Tok-
enize does not terminate args with a null pointer.
Alef
Of these routines, only tokenize is in Alef.
SOURCE
/sys/src/libc/port/getfields.c
/sys/src/libc/port/tokenize.c
SEE ALSO
strtok in strcat(2)GETFIELDS(2)