Search Results

Search: Posts Made By: RickS
1,347
Posted By yinyuemi
echo "<aaa bbb="xxxx" params="@abc@ @defghi@...
echo "<aaa bbb="xxxx" params="@abc@ @defghi@ @j@"></aaa>
<aaa params="@abc@ @defghi@">value</aaa><aaa params="@klm@ @nopq@ @rstu@"></aaa>
<aaa params="@v@ @wxy@ @z@"></aaa>" |
gawk...
1,347
Posted By ctsgnb
awk '/params/{gsub(" @","\"...
awk '/params/{gsub(" @","\" params=\"",$0);i=1;do{sub("params","param"(i),$0);i++}while(match($0,/params/))}1' infile[ctsgnb@shell ~/sand]$ cat tst
<aaa bbb="xxxx" params="@abc@ @defghi@ @j@"></aaa>...
1,875
Posted By frank_rizzo
that is correct - whitespace is removed by the...
that is correct - whitespace is removed by the shell.

I suggest removing it via the built-in functionality rather then use sed.

ie:
search_string=${var//\//\\/}
1,875
Posted By anbu23
search_string=`echo "$var" | sed...
search_string=`echo "$var" | sed 's@/@\\\/@g'`
6,534
Posted By Aia
The @ is not a character part of the regex. It is...
The @ is not a character part of the regex. It is the boundary symbol Scottn choose to build the substitution for the sed utility.
Usually sed uses `/' with the `s' as in sed 's/old/new/' but when...
6,534
Posted By Scott
$ P=/home/smith/packages/cat/abc/def $ echo $P...
$ P=/home/smith/packages/cat/abc/def
$ echo $P | sed "s@\(.*/packages/[^/]*/\).*@\1@"
/home/smith/packages/cat/
3,763
Posted By Scrutinizer
Hi RickS, set without options assigns its...
Hi RickS,

set without options assigns its arguments to the variables $1, $2, etc.. For instance:
# set a b
# echo $1
a
# echo $2
b

-- signifies the end of options. Anything that comes...
3,763
Posted By Scrutinizer
while read line do eval set -- "$line" ...
while read line
do
eval set -- "$line"
echo "$4"
done < infile
or:
print4()
{
echo "$4"
}

while read line
do
eval print4 "$line"
done < infile

or (ksh93/bash):
while read...
2,041
Posted By tukuyomi
Using built-in bash parameter expansion: ...
Using built-in bash parameter expansion:
d='/cat/dog/bird/giraffe/ant'; d=${d#*bird/}; echo ${d%/ant*}
giraffe
See man bash -> 'Parameter Expansion' for more infos
2,041
Posted By vgersh99
#.*/bird/\([^/][^/]*\)/ant.*# .*/bird/ ...
#.*/bird/\([^/][^/]*\)/ant.*#

.*/bird/ - anything followed by '/bird/'
\([^/][^/]*\) - followed a FIRST 'capture' of: anything, but '/' repeated 0 or more times
/and.* -...
2,041
Posted By vgersh99
many ways to skin that cat: echo...
many ways to skin that cat:

echo '/cat/dog/bird/giraffe/ant' | sed 's#.*/bird/\([^/][^/]*\)/ant.*#\1#g'
2,955
Posted By cola
Can anyone post alternative sed command to do the...
Can anyone post alternative sed command to do the same thing?
Actually replacing this "/^a/!"
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 02:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy