I don't think I made myself clear. Let me give an example. Suppose the file I have is:
I want the sed command to replace only the first two instances of the string "test" with "found_it", i.e. the output should contain:
i.e. the string test should only be replaced with found_it if it occurs after a pipe or at the beginning of the line. I suppose this can be achieved with :
but shouldn't this be achievable using regex patterns too?
Hi, excuse me for my poor english.
My problem is that:
I have a File
i want to add to each line of that file two strings: one at the beginning of the line, one at the ending.
string1="abcd"
string2="efgh"
i want $string1 content $string2 for each line.
Is that possible? (3 Replies)
I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed).
AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC
MY * A02 RESALE 6990788000 Y... (3 Replies)
Hi all,
using VI, can anyone tell me how to add some characters onto the end of a line where the line begins with certain charactars eg
a,b,c,.......,
r,s,t,........,
a,b,c,.......,
all lines in the above example starting with a,b,c, I want to add an x at the end of the line so the... (6 Replies)
What is a regex for "the dalai lama, his holiness the"
that would just grab "the dalai lama"
and one that would just grab "his holiness the"? Both should exclude the comma..
I was trying '^.*' and many variants with no luck. (6 Replies)
Well here goes:
I tried to write a batch file that adds a specific fixed text to each line of an already existing text file.
for the adding text infront of each line I tried this:
for /F "delims=" %%j in (list.txt) do echo.STARTTEXT\%%j >> list.txt
for adding text after each line I... (0 Replies)
How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
I have been trying to insert a line after a regex but I can't do it. Here is the code I am using:
cat saved_doc
SET type = type1
SET type = STORE = y
/vol/san_e1
/vol/san_5
/vol/san_e9
/vol/san_e11
/vol/san_e12
/vol/san_e13
/vol/san_e14
/vol/san_e16
/vol/san_e17
/vol/san_e18... (4 Replies)
Hi,
I have a specific requirement to add text at the beginning and end of a plain text file. I tried to use "sed" with '1i' and '$a' flags but these required two separate "sed" commands separated with "|".
I am looking for some command/option to join these two in single command parameter.
... (6 Replies)
I would like to insert n number of characters at the beginning of each line that starts with a given character. If possible, I would be most appreciative for a sed or awk solution.
Given the data below, I would like to be able to insert either 125 spaces or 125 "-" at the beginning of every line... (6 Replies)
Discussion started by: jvoot
6 Replies
LEARN ABOUT REDHAT
wildmat
WILDMAT(3) Library Functions Manual WILDMAT(3)NAME
wildmat - perform shell-style wildcard matching
SYNOPSIS
int
wildmat(text, pattern)
char *text;
char *pattern;
DESCRIPTION
Wildmat is part of libinn(3). Wildmat compares the text against the pattern and returns non-zero if the pattern matches the text. The
pattern is interpreted according to rules similar to shell filename wildcards, and not as a full regular expression such as those handled
by the grep(1) family of programs or the regex(3) or regexp(3) set of routines.
The pattern is interpreted as follows:
x Turns off the special meaning of x and matches it directly; this is used mostly before a question mark or asterisk, and is not spe-
cial inside square brackets.
? Matches any single character.
* Matches any sequence of zero or more characters.
[x...y]
Matches any single character specified by the set x...y. A minus sign may be used to indicate a range of characters. That is,
[0-5abc] is a shorthand for [012345abc]. More than one range may appear inside a character set; [0-9a-zA-Z._] matches almost all of
the legal characters for a host name. The close bracket, ], may be used if it is the first character in the set. The minus sign,
-, may be used if it is either the first or last character in the set.
[^x...y]
This matches any character not in the set x...y, which is interpreted as described above. For example, [^]-] matches any character
other than a close bracket or minus sign.
HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> in 1986, and posted to Usenet several times since then, most notably in comp.sources.misc in
March, 1991.
Lars Mathiesen <thorinn@diku.dk> enhanced the multi-asterisk failure mode in early 1991.
Rich and Lars increased the efficiency of star patterns and reposted it to comp.sources.misc in April, 1991.
Robert Elz <kre@munnari.oz.au> added minus sign and close bracket handling in June, 1991.
This is revision 1.2.6.1, dated 2000/08/17.
SEE ALSO grep(1), regex(3), regexp(3).
WILDMAT(3)