Re: sed question!

2017-02-14 Thread Cameron Simpson

On 12Feb2017 20:06, bruce  wrote:

Got a quick sed question now..

test file::
head -2  sed.dat
228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883


I always say "sed 2q" instead of "head -2", myself.


want to simply truncate/search/replace the end of each line starting
with the ","
to get

228d98f0_f16a_11e6_9544_1ad613f05f7b
22b93712_f16a_11e6_a6ad_1ad613f05f7b

the following isn't working
sed -i 's/\,+\$//'  sed.dat
sed -i 's/\,+$//'  sed.dat


sed 's/,.*//'

1: You're in single quotes (generally desirable), so "," and "$" are not shell 
special characters and need no backslashes.


2: I don't know what your intend with the "+" is. Firstly, by default sed uses 
Basic Regular Expressions, which do not include "+". Secondly, "+" is a regexp 
character meaning "1 or more or the preceeding item", so you're saying "delete 
the first instance of one or more commas". Except that with BREs you're saying 
"delete the first comma followed by a plus" because "+" is not special.


I'd test without the "-i" until you have things working.

Cheers,
Cameron Simpson 
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question!

2017-02-12 Thread Jon LaBadie
On Sun, Feb 12, 2017 at 08:06:28PM -0500, bruce wrote:
> Hey guys.
> 
> Thanks for the delete replies..
> 
> Got a quick sed question now..
> 
> test file::
> head -2  sed.dat
> 228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883
> 
> want to simply truncate/search/replace the end of each line starting
> with the ","
> to get
> 
> 228d98f0_f16a_11e6_9544_1ad613f05f7b
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b
> 
> the following isn't working
>  sed -i 's/\,+\$//'  sed.dat
> 
>  sed -i 's/\,+$//'  sed.dat
> 
> I'm sure it's simple/trivial...
> 
Several problems.  The sed's I know don't use extended RE syntax
and '+' is a repetition character of extended RE.  Some sed's
might allow its use with the '-r' option.  And maybe there are
some sed's that do use extended RE.

Comma is not typically a special character, so no need to escape.

In pattern matching by the shell, the '*' repetition character
does not reference the preceeding character.  RE repetition
characters (* in basic and + and ? in extended) always refer
to repetitions of the preceeding character.  Thus your pattern
(if and extended RE) would be looking for a string of commas,
NOT one comma followed by a string of any char.

Try something like "sed -r -i 's/,[0-9]+$//'".
or "sed -i 's/,[0-9]*$//'" or if uncertain they
will be digits, but certain they will not be
commas (i.e. you want to delete the last comma
onward) try "sed -i 's/,[^,]*$//'

Jon
-- 
Jon H. LaBadie  jo...@jgcomp.com
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question!

2017-02-12 Thread Steve Forsythe
On 02/12/2017 08:06 PM, bruce wrote:
> Hey guys.
> 
> Thanks for the delete replies..
> 
> Got a quick sed question now..
> 
> test file::
> head -2  sed.dat
> 228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883
> 
> want to simply truncate/search/replace the end of each line starting
> with the ","
> to get
> 
> 228d98f0_f16a_11e6_9544_1ad613f05f7b
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b
> 
> the following isn't working
>  sed -i 's/\,+\$//'  sed.dat
> 
>  sed -i 's/\,+$//'  sed.dat
> 
> I'm sure it's simple/trivial...
> 
> thoughts...
> ___
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
> 
How about:
sed  's/,[0-9]\+$//' < sed.dat
228d98f0_f16a_11e6_9544_1ad613f05f7b
22b93712_f16a_11e6_a6ad_1ad613f05f7b

which removes a comma followed by 1 or more digits from the end of the
line. Or if you don't care what comes after the comma, then

sed  's/,.*$//' < sed.dat

will remove the comma and anything after it.





signature.asc
Description: OpenPGP digital signature
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question!

2017-02-12 Thread Clifford Snow
I'm a awk user.
cat sed.dat | awk -F"," '{print $1}'

or

awk -F"," '{print $1}' sed.dat

On Sun, Feb 12, 2017 at 5:06 PM, bruce  wrote:

> Hey guys.
>
> Thanks for the delete replies..
>
> Got a quick sed question now..
>
> test file::
> head -2  sed.dat
> 228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883
>
> want to simply truncate/search/replace the end of each line starting
> with the ","
> to get
>
> 228d98f0_f16a_11e6_9544_1ad613f05f7b
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b
>
> the following isn't working
>  sed -i 's/\,+\$//'  sed.dat
>
>  sed -i 's/\,+$//'  sed.dat
>
> I'm sure it's simple/trivial...
>
> thoughts...
> ___
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
>



-- 
@osm_seattle
osm_seattle.snowandsnow.us
OpenStreetMap: Maps with a human touch
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question!

2017-02-12 Thread Fred Smith
On Sun, Feb 12, 2017 at 08:06:28PM -0500, bruce wrote:
> Hey guys.
> 
> Thanks for the delete replies..
> 
> Got a quick sed question now..
> 
> test file::
> head -2  sed.dat
> 228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883
> 
> want to simply truncate/search/replace the end of each line starting
> with the ","
> to get
> 
> 228d98f0_f16a_11e6_9544_1ad613f05f7b
> 22b93712_f16a_11e6_a6ad_1ad613f05f7b
> 
> the following isn't working
>  sed -i 's/\,+\$//'  sed.dat
> 
>  sed -i 's/\,+$//'  sed.dat
> 
> I'm sure it's simple/trivial...

I'm far from a sed expert, but were I doing that I'd start with this,
and move on from there as required:

's/,.*$//'

which is: comma followed by zero or more of anything, followed by end of line.

I think your expression says:
one or more commas, followed by end of line.

Fred

-- 
 Fred Smith -- fre...@fcshome.stoneham.ma.us -
  The eyes of the Lord are everywhere, 
keeping watch on the wicked and the good.
- Proverbs 15:3 (niv) -
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question!

2017-02-12 Thread Gordon Messmer

On 02/12/2017 05:06 PM, bruce wrote:

the following isn't working

  sed -i 's/\,+$//'  sed.da



That would remove one or more commas, if they immediately precede the 
end of the line.


You mean:

sed 's/,.*$//'

or:

cut -f1 -d,
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


sed question!

2017-02-12 Thread bruce
Hey guys.

Thanks for the delete replies..

Got a quick sed question now..

test file::
head -2  sed.dat
228d98f0_f16a_11e6_9544_1ad613f05f7b,1486934882
22b93712_f16a_11e6_a6ad_1ad613f05f7b,1486934883

want to simply truncate/search/replace the end of each line starting
with the ","
to get

228d98f0_f16a_11e6_9544_1ad613f05f7b
22b93712_f16a_11e6_a6ad_1ad613f05f7b

the following isn't working
 sed -i 's/\,+\$//'  sed.dat

 sed -i 's/\,+$//'  sed.dat

I'm sure it's simple/trivial...

thoughts...
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org


Re: sed question

2016-07-21 Thread R. G. Newbury

Date: Thu, 21 Jul 2016 08:00:44 -0400
From: bruce 
Subject: sed question




Hey guys..

Sed question.. should be simple, but after stack/net searches, lots or
trials.. can't seem to get it..

I've got a case

any thoughts on how to handle the parens would be cool!

just irks me that I couldn't see what I missed.


You cannot 'escape' the parens since '\(' and '\)' are defined 'codes' 
like ^ & and $.


\( marks the start  of an internal variable to be recorded, and \) marks 
the end, substitution in the output side uses \1 (or \2,\3, or as many 
as needed)


So sed -i -e "s#('txt')#'(\/dir\/txt)'#g" foo

should work.

NOTE: 1) sed inplace replacement
2) using extended grep
3) for clarity, the usual use of '/' for the 's' replacement is changed 
to '#'

4) the global replacement marker, usually ', is changed to "

sed gets confused when dealing with mixed ' and " markers,  I suspect 
that this is your problem. So use the opposite marker outside the sed 
replacement, when you have one inside.




--
 R. Geoffrey Newbury
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread Jon LaBadie
On Thu, Jul 21, 2016 at 08:00:44AM -0400, bruce wrote:
> Hey guys..
> 
> Sed question.. should be simple, but after stack/net searches, lots or
> trials.. can't seem to get it..
> 
> I've got a case
> 
> foo('txt')
> foo("txt")
> 
> I'd like to have
> 
> foo('/dir1/txt')
> foo("/dir1/txt")
> 
> Now. I do a simple sed search/replace if it just focuses on the txt, but
> crafting a sed that uses the entire input as a search due to the parens
> '()' is a bit painful!  Doing the sed using the \( for the ( wasn't quite
> successful!
> 
> for just the txt..
> 
> sed -i 's/'txt'/'dir1/txt'/' *files.dat
> sed -i 's/"txt"/"dir1/txt"/' *files.dat
> 
> these work...
> 
> any thoughts on how to handle the parens would be cool!
> 
> just irks me that I couldn't see what I missed.
> 

Two more possibilities (the short output lines were unchanged):

# search for entire string, replace only txt
$ sed '/foo(.txt.)/s,txt,/dir/txt,' tst.txt
foo('/dir/txt')
bar('txt')
foo('bar')
foo("/dir/txt")
bar("txt")
foo("bar")

# capture unchanging parts as \1 and \2 using grouping \( & \)
$ sed 's,\(foo(.\)txt\(.)\),\1/dir/txt\2,' tst.txt
foo('/dir/txt')
bar('txt')
foo('bar')
foo("/dir/txt")
bar("txt")
foo("bar")

-- 
Jon H. LaBadie  jo...@jgcomp.com
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread bruce
thanks.. guys..

just a brain screwup.. should be ok now.. thanks for the eyeballs..

owe you guys oj!



On Thu, Jul 21, 2016 at 11:01 AM, Tethys  wrote:

> On Thu, Jul 21, 2016 at 1:00 PM, bruce  wrote:
>
> > Now. I do a simple sed search/replace if it just focuses on the txt, but
> > crafting a sed that uses the entire input as a search due to the parens
> '()'
> > is a bit painful!  Doing the sed using the \( for the ( wasn't quite
> > successful!
>
> localhost:~% sed 's,^foo(\(.\)txt\(.\))$,foo(\1/dir1/txt\2),' << EOF
> foo('txt')
> foo("txt")
> EOF
> foo('/dir1/txt')
> foo("/dir1/txt")
>
> Tet
>
> --
> I saw cout being shifted "Hello world" times to the left and stopped
> right there. — Steve Gonedes
> --
> users mailing list
> users@lists.fedoraproject.org
> To unsubscribe or change subscription options:
> https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> Have a question? Ask away: http://ask.fedoraproject.org
>
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread Tethys
On Thu, Jul 21, 2016 at 1:00 PM, bruce  wrote:

> Now. I do a simple sed search/replace if it just focuses on the txt, but
> crafting a sed that uses the entire input as a search due to the parens '()'
> is a bit painful!  Doing the sed using the \( for the ( wasn't quite
> successful!

localhost:~% sed 's,^foo(\(.\)txt\(.\))$,foo(\1/dir1/txt\2),' << EOF
foo('txt')
foo("txt")
EOF
foo('/dir1/txt')
foo("/dir1/txt")

Tet

-- 
I saw cout being shifted "Hello world" times to the left and stopped
right there. — Steve Gonedes
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread Tom Rivers

On 7/21/2016 8:26 AM, bruce wrote:

Hey Tudor, and others..

The test sed I posted works for doing a search/replace of the text 
inside the parens...


> foo('txt')
> foo("txt")

however.. if i wanted to craft a sed that uses the entire 
>>foo('txt')<< as the search.. then I run into the need to handle the 
parens.. and that's the issue..


this doesn't work

sed -i 's/foo('txt')/foo('/dir1/txt') /' *files.dat
sed -i 's/foo\('txt'\)/foo\('/dir1/txt'\)/' *files.dat


If you swap out the apostrophes with quotation marks it should work - 
Bash is what I think is getting in your way.  On Fedora 23 I have the 
following in a text file called test.txt:


The 'test' case for changing foo('txt') to foo("txt") without changing 
bar('txt') to bar("txt") example.


I used the following sed command:

 sed -e "s/foo('txt')/foo(\"txt\")/g" test.txt

This is the output:

The 'test' case for changing foo("txt") to foo("txt") without changing 
bar('txt') to bar("txt") example.




Tom
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread bruce
hey todor..

I'll give it a try.. I was thinking it's the parens.. overlooked the fact
that i introduced '/' in the replace.. which might have caused issue.. but
the '/' was successful in the test with just the text inside the ()..





On Thu, Jul 21, 2016 at 8:59 AM, Todor Petkov 
wrote:

> On Thu, Jul 21, 2016 at 3:26 PM, bruce  wrote:
> > Hey Tudor, and others..
> >
> > The test sed I posted works for doing a search/replace of the text inside
> > the parens...
> >
> >> foo('txt')
> >> foo("txt")
> >
> > however.. if i wanted to craft a sed that uses the entire >>foo('txt')<<
> as
> > the search.. then I run into the need to handle the parens.. and that's
> the
> > issue..
> >
> > this doesn't work
> >
> > sed -i 's/foo('txt')/foo('/dir1/txt') /' *files.dat
> > sed -i 's/foo\('txt'\)/foo\('/dir1/txt'\)/' *files.dat
>
>
> cat /tmp/1.txt ; echo; sed -e
> "s#foo('txt')#foo('/dir1/txt')#;s#foo(\"txt\")#foo('/dir1/txt')#"
> /tmp/1.txt
> foo('txt')
> foo("txt")
>
> foo('/dir1/txt')
> foo('/dir1/txt')
>
>
> This?
> --
> users mailing list
> users@lists.fedoraproject.org
> To unsubscribe or change subscription options:
> https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> Have a question? Ask away: http://ask.fedoraproject.org
>
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread Todor Petkov
On Thu, Jul 21, 2016 at 3:26 PM, bruce  wrote:
> Hey Tudor, and others..
>
> The test sed I posted works for doing a search/replace of the text inside
> the parens...
>
>> foo('txt')
>> foo("txt")
>
> however.. if i wanted to craft a sed that uses the entire >>foo('txt')<< as
> the search.. then I run into the need to handle the parens.. and that's the
> issue..
>
> this doesn't work
>
> sed -i 's/foo('txt')/foo('/dir1/txt') /' *files.dat
> sed -i 's/foo\('txt'\)/foo\('/dir1/txt'\)/' *files.dat


cat /tmp/1.txt ; echo; sed -e
"s#foo('txt')#foo('/dir1/txt')#;s#foo(\"txt\")#foo('/dir1/txt')#"
/tmp/1.txt
foo('txt')
foo("txt")

foo('/dir1/txt')
foo('/dir1/txt')


This?
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread bruce
Hey Tudor, and others..

The test sed I posted works for doing a search/replace of the text inside
the parens...

> foo('txt')
> foo("txt")

however.. if i wanted to craft a sed that uses the entire >>foo('txt')<< as
the search.. then I run into the need to handle the parens.. and that's the
issue..

this doesn't work

sed -i 's/foo('txt')/foo('/dir1/txt') /' *files.dat
sed -i 's/foo\('txt'\)/foo\('/dir1/txt'\)/' *files.dat

thanks






On Thu, Jul 21, 2016 at 8:14 AM, Todor Petkov 
wrote:

> On Thu, Jul 21, 2016 at 3:00 PM, bruce  wrote:
> > Hey guys..
> >
> > Sed question.. should be simple, but after stack/net searches, lots or
> > trials.. can't seem to get it..
> >
> > I've got a case
> >
> > foo('txt')
> > foo("txt")
> >
> > I'd like to have
> >
> > foo('/dir1/txt')
> > foo("/dir1/txt")
> >
> > Now. I do a simple sed search/replace if it just focuses on the txt, but
> > crafting a sed that uses the entire input as a search due to the parens
> '()'
> > is a bit painful!  Doing the sed using the \( for the ( wasn't quite
> > successful!
> >
> > for just the txt..
> >
> > sed -i 's/'txt'/'dir1/txt'/' *files.dat
> > sed -i 's/"txt"/"dir1/txt"/' *files.dat
> >
> > these work...
> >
> > any thoughts on how to handle the parens would be cool!
> >
> > just irks me that I couldn't see what I missed.
> >
> > thanks!
>
> Try like this:
>
>  cat /tmp/1.txt
> foo('/dir1/txt')
>
>  sed -e 's#'txt'#'dir1/txt'#' /tmp/1.txt
> foo('/dir1/dir1/txt')
>
> Or:
> sed -e  's/'txt'/'dir1\\/txt'/' /tmp/1.txt
>
> You need to escape the / in the replacement string.
> --
> users mailing list
> users@lists.fedoraproject.org
> To unsubscribe or change subscription options:
> https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> Have a question? Ask away: http://ask.fedoraproject.org
>
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question

2016-07-21 Thread Todor Petkov
On Thu, Jul 21, 2016 at 3:00 PM, bruce  wrote:
> Hey guys..
>
> Sed question.. should be simple, but after stack/net searches, lots or
> trials.. can't seem to get it..
>
> I've got a case
>
> foo('txt')
> foo("txt")
>
> I'd like to have
>
> foo('/dir1/txt')
> foo("/dir1/txt")
>
> Now. I do a simple sed search/replace if it just focuses on the txt, but
> crafting a sed that uses the entire input as a search due to the parens '()'
> is a bit painful!  Doing the sed using the \( for the ( wasn't quite
> successful!
>
> for just the txt..
>
> sed -i 's/'txt'/'dir1/txt'/' *files.dat
> sed -i 's/"txt"/"dir1/txt"/' *files.dat
>
> these work...
>
> any thoughts on how to handle the parens would be cool!
>
> just irks me that I couldn't see what I missed.
>
> thanks!

Try like this:

 cat /tmp/1.txt
foo('/dir1/txt')

 sed -e 's#'txt'#'dir1/txt'#' /tmp/1.txt
foo('/dir1/dir1/txt')

Or:
sed -e  's/'txt'/'dir1\\/txt'/' /tmp/1.txt

You need to escape the / in the replacement string.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


sed question

2016-07-21 Thread bruce
Hey guys..

Sed question.. should be simple, but after stack/net searches, lots or
trials.. can't seem to get it..

I've got a case

foo('txt')
foo("txt")

I'd like to have

foo('/dir1/txt')
foo("/dir1/txt")

Now. I do a simple sed search/replace if it just focuses on the txt, but
crafting a sed that uses the entire input as a search due to the parens
'()' is a bit painful!  Doing the sed using the \( for the ( wasn't quite
successful!

for just the txt..

sed -i 's/'txt'/'dir1/txt'/' *files.dat
sed -i 's/"txt"/"dir1/txt"/' *files.dat

these work...

any thoughts on how to handle the parens would be cool!

just irks me that I couldn't see what I missed.

thanks!
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


Re: sed question??

2015-06-06 Thread Cameron Simpson

On 06Jun2015 21:53, bruce  wrote:

Evening..


Morning...


As a test, the following is an attempt to replace "text" from a test
file with "text" from an external file.

aa=$(cat www1.txt)


BTW, this can be written:

 aa=$(< www1.txt)


sed -i "s*#\tISSUES/NOTES::*$aa*g" foo.py1

When I check the foo.py1 file, I get "$aa" in the file, instead of the
replacement text.


Are you sure you used the exact command above? If you have used single quote I 
would have expected such a result, but not with double quotes.



The test is using replacement delimeters for the sed, as the
replacement text has slashes...


I'm fond of ^G for this purpose:-)


thanks for any pointers.


When debugging sed scripts and other fiddly shell commands it is often useful 
to trace the actual executed command, thus:


 ( set -x; sed -i "s*#\tISSUES/NOTES::*$aa*g" foo.py1 )

which will should the issued sed command, after the shell has done its 
mangling.


Cheers,
Cameron Simpson 
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


sed question??

2015-06-06 Thread bruce
Evening..

As a test, the following is an attempt to replace "text" from a test
file with "text" from an external file.

aa=$(cat www1.txt)
sed -i "s*#\tISSUES/NOTES::*$aa*g" foo.py1

When I check the foo.py1 file, I get "$aa" in the file, instead of the
replacement text.

The test is using replacement delimeters for the sed, as the
replacement text has slashes...

thanks for any pointers.
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org