Re: grep replacement using sed is behaving oddly

2022-10-22 Thread Max Nikulin
On 22/10/2022 20:23, Gary Dale wrote:     sed -i '//d' *.html did the trick. I would suggest you to use more specific pattern to avoid removing of meaningful text due to a lost newline character: sed -i -e '/^\s*]*>\s*$/d' "." in regexp may be a sou

Re: grep replacement using sed is behaving oddly

2022-10-22 Thread Gary Dale
ave a line in a lot of HTML files that I'd like to remove. The line is:     I'm testing the sed command to remove it on just one file. When it works, I'll run it against *.html. My command is:  sed -i -s 's/\s*\//g' history.html Unfortunately, the replacement

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread tomas
On Sat, Oct 22, 2022 at 10:32:24AM +0700, Max Nikulin wrote: > On 22/10/2022 02:09, The Wanderer wrote: > > > > 'info sed', section 'sed regular expressions', subsection 'regular > > expression extensions': > > While a reader may find more

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread Max Nikulin
On 22/10/2022 02:09, The Wanderer wrote: 'info sed', section 'sed regular expressions', subsection 'regular expression extensions': While a reader may find more interesting stuff lying around while traveling by this path, there is a shorthand info

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread The Wanderer
On 2022-10-21 at 16:16, Greg Wooledge wrote: > On Fri, Oct 21, 2022 at 03:09:32PM -0400, The Wanderer wrote: > >> IOW, each seems to be half of the usual '\b' (edge of a word) set. >> With the default sed behavior (not sure whether that's basic >>

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread Greg Wooledge
On Fri, Oct 21, 2022 at 03:09:32PM -0400, The Wanderer wrote: > IOW, each seems to be half of the usual '\b' (edge of a word) set. With > the default sed behavior (not sure whether that's basic regular > expressions or extended regular expressions, in the nomenclature of t

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread David Wright
n a > > > lot > > > of HTML files that I'd like to remove. The line is: > > > > > >     > > > > > > I'm testing the sed command to remove it on just one file. When it works, > > > I'll run it against *.html. M

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread The Wanderer
On 2022-10-21 at 14:15, Greg Wooledge wrote: > So... yeah, \< and/or \> clearly have some special meaning to GNU > sed. Good luck figuring out what that is. 'info sed', section 'sed regular expressions', subsection 'regular expression extensions': >&

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread tomas
n a > > > lot > > > of HTML files that I'd like to remove. The line is: > > > > > >     > > > > > > I'm testing the sed command to remove it on just one file. When it works, > > > I'll run it against *.html. M

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread Greg Wooledge
> > >     > > > > I'm testing the sed command to remove it on just one file. When it works, > > I'll run it against *.html. My command is: > > > >  sed -i -s 's/\s*\//g' history.html > > > > Unfortunately, the repl

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread tomas
On Fri, Oct 21, 2022 at 01:50:29PM -0400, Greg Wooledge wrote: > On Fri, Oct 21, 2022 at 01:21:44PM -0400, Gary Dale wrote: > >  sed -i -s 's/\s*\//g' history.html > > > > Unfortunately, the replacement doesn't remove the line but rather leaves me > > w

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread tomas
On Fri, Oct 21, 2022 at 01:21:44PM -0400, Gary Dale wrote: > I'm hoping someone can tell me what I'm doing wrong. I have a line in a lot > of HTML files that I'd like to remove. The line is: > >         > > I'm testing the sed command to remove it on ju

Re: grep replacement using sed is behaving oddly

2022-10-21 Thread Greg Wooledge
On Fri, Oct 21, 2022 at 01:21:44PM -0400, Gary Dale wrote: >  sed -i -s 's/\s*\//g' history.html > > Unfortunately, the replacement doesn't remove the line but rather leaves me > with: > >     <;"> The 's' command in sed doesn

grep replacement using sed is behaving oddly

2022-10-21 Thread Gary Dale
I'm hoping someone can tell me what I'm doing wrong. I have a line in a lot of HTML files that I'd like to remove. The line is:     I'm testing the sed command to remove it on just one file. When it works, I'll run it against *.html. My command is

Re: POSIX compliant sed making newline character

2020-08-22 Thread john doe
On 8/22/2020 6:33 PM, Andrei POPESCU wrote: On Vi, 21 aug 20, 21:06:05, john doe wrote: When I can not get the command I want, I break it down to the simplest command as possible then I build from there to the command I realy want. Have you considered that solution(s) found might not be usabl

Re: POSIX compliant sed making newline character

2020-08-22 Thread Andrei POPESCU
On Vi, 21 aug 20, 21:06:05, john doe wrote: > > When I can not get the command I want, I break it down to the simplest > command as possible then I build from there to the command I realy want. Have you considered that solution(s) found might not be usable in the bigger context, basically wastin

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
On 8/21/2020 9:00 PM, Greg Wooledge wrote: On Fri, Aug 21, 2020 at 08:51:44PM +0200, john doe wrote: Okay, it uses the same syntax as for a subshell '$()'. No, one of them is $'' and the other is $(). They have nothing in common. One of them is a form of quoting. It acts just like '' except

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 08:51:44PM +0200, john doe wrote: > Okay, it uses the same syntax as for a subshell '$()'. No, one of them is $'' and the other is $(). They have nothing in common. One of them is a form of quoting. It acts just like '' except that it performs various backslash expansion

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
On 8/21/2020 8:37 PM, Greg Wooledge wrote: On Fri, Aug 21, 2020 at 02:35:35PM -0400, Greg Wooledge wrote: No. Use $'...' instead of '...'. sed '/line1/{N;N;a line-to-add\n}' input-file Crap. Of course I meant to write sed $'/line1/{N;N;a line-to-add\

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 02:35:35PM -0400, Greg Wooledge wrote: > No. Use $'...' instead of '...'. > > sed '/line1/{N;N;a line-to-add\n}' input-file Crap. Of course I meant to write sed $'/line1/{N;N;a line-to-add\n}' input-file

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 08:09:26PM +0200, john doe wrote: > On 8/21/2020 7:51 PM, Greg Wooledge wrote: > > If you're doing this from bash, you could use bash's special $'...' > > quoting to pass a newline encoded as \n . > > So something like the followi

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
On 8/21/2020 7:51 PM, Greg Wooledge wrote: On Fri, Aug 21, 2020 at 07:49:07PM +0200, john doe wrote: Hello all, I'm trying to use the command provided at (1): $ sed '/pattern{N;N;a try\d10}' input-file sed: -e expression #1, char 0: unmatched `{' Are you missing a seco

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 07:49:07PM +0200, john doe wrote: > Hello all, > > I'm trying to use the command provided at (1): > > $ sed '/pattern{N;N;a try\d10}' input-file > sed: -e expression #1, char 0: unmatched `{' Are you missing a second / cha

POSIX compliant sed making newline character

2020-08-21 Thread john doe
Hello all, I'm trying to use the command provided at (1): $ sed '/pattern{N;N;a try\d10}' input-file sed: -e expression #1, char 0: unmatched `{' As I understanded, I should make a newline before the right brace. I thought that '\d10' should do it but as shown

Re: sed question

2019-12-07 Thread Michael
On Friday, December 6, 2019 6:06:10 PM CET, songbird wrote: result=`echo "summary: \"\"" | sed -e "s/^summary: .*$/summary: \"${old_summary}\"/"` of course this doesn't work. since you use '/' (slash) as delimiter in the sed expr

Re: sed question

2019-12-07 Thread Andrei POPESCU
On Vi, 06 dec 19, 14:50:51, Greg Wooledge wrote: > On Fri, Dec 06, 2019 at 02:40:49PM -0500, songbird wrote: > > Greg Wooledge wrote: > > ... > > > Ideally, you'd just stop trying to use sed with user-supplied variables > > > injected into the code. Sed was n

Re: sed question

2019-12-07 Thread Andrei POPESCU
On Vi, 06 dec 19, 14:40:49, songbird wrote: > > the point of doing something in bash is to do it quick and > see if the concept is useful enough. if enough people decide > to use it then it can be more formalized. We often build prototypes / proof-of-concept / experiments that live much longe

Re: sed question

2019-12-07 Thread Jeremy Nicoll
On Sat, 7 Dec 2019, at 14:20, songbird wrote: > The Wanderer wrote: > > ... about various characters and then @ in particular ... > > > As far as I can see, at least on my keyboard, that pretty much just > > leaves @. It does still sometimes occur in paths and filenames, so it's > > not really i

Re: Alternate delimiters (for sed) above decimal 127? (was Re: sed question)

2019-12-07 Thread David Wright
gt; > leaves @. It does still sometimes occur in paths and filenames, so it's > > not really ideal, but it's probably less common there than any of the > > non-special-meaning others. > > I'm not the OP, but thanks for the explanation / discussion. > > I just

Re: sed question

2019-12-07 Thread songbird
ter, e.g. '|'. > > According to the manual[1][2] any other character is accepted. > > [1] https://www.gnu.org/software/sed/manual/sed.html#The-_0022s_0022-Command > [2] as with many (most? all?) GNU programs the full documentation is=20 > available only as a Texinfo manual, not a man page. yeah... songbird

Re: sed question

2019-12-07 Thread songbird
The Wanderer wrote: ... about various characters and then @ in particular ... > As far as I can see, at least on my keyboard, that pretty much just > leaves @. It does still sometimes occur in paths and filenames, so it's > not really ideal, but it's probably less common there than any of the >

Alternate delimiters (for sed) above decimal 127? (was Re: sed question)

2019-12-07 Thread rhkramer
e > non-special-meaning others. I'm not the OP, but thanks for the explanation / discussion. I just have a wild idea / question. Those are (iirc) all ASCII characters, (basically 7 bits) (yes, I know they are in an 8 bit byte), I wonder if SED (and AWK) could use something in, well, is it ca

Re: sed question

2019-12-07 Thread The Wanderer
On 2019-12-07 at 04:43, Andrei POPESCU wrote: > On Vi, 06 dec 19, 16:15:51, songbird wrote: > >> The Wanderer wrote: >>> >>> For example, 's/hello/newstring/' would be a valid sed >>> 's'-expression, but 's/a/b/newstring/'

Re: sed question

2019-12-07 Thread Andrei POPESCU
On Vi, 06 dec 19, 16:15:51, songbird wrote: > The Wanderer wrote: > > > > For example, 's/hello/newstring/' would be a valid sed 's'-expression, > > but 's/a/b/newstring/' would not; the former contains three instances of > > the delim

Re: sed question

2019-12-06 Thread songbird
Erik Christiansen wrote: ... > If the sed implementation of variable regexes proves problematic, then > there's awk with its Dynamic Regexps. (Section 2.8 of the pdf manual > floating about out there.) > > With its C-like syntax, it's less write-only than perl, perhaps be

Re: sed question

2019-12-06 Thread Erik Christiansen
On 06.12.19 14:40, songbird wrote: > Greg Wooledge wrote: > ... > > Ideally, you'd just stop trying to use sed with user-supplied variables > > injected into the code. Sed was never built to be safe for that kind of > > work. > > sed was designed to

Re: sed question

2019-12-06 Thread songbird
Greg Wooledge wrote: ... > If you insist on doing #1, so be it. It's your damned computer, and your > damned problem. I can only warn you and be ignored so many times > before I give up and let your fuck yourself, as you so vehemently and > stubbornly eager to do. i appreciate the actual expla

Re: sed question

2019-12-06 Thread songbird
The Wanderer wrote: >songbird wrote: ... >> sed was designed to operate on streams. a sequence of characters is >> a stream. i don't see any reason why putting the variable into the >> middle of that expression means anything different. > > Because sed doesn

Re: sed question

2019-12-06 Thread The Wanderer
On 2019-12-06 at 14:40, songbird wrote: > Greg Wooledge wrote: ... >> Ideally, you'd just stop trying to use sed with user-supplied >> variables injected into the code. Sed was never built to be safe >> for that kind of work. > > sed was designed to operate on st

Re: sed question

2019-12-06 Thread Greg Wooledge
On Fri, Dec 06, 2019 at 02:40:49PM -0500, songbird wrote: > Greg Wooledge wrote: > ... > > Ideally, you'd just stop trying to use sed with user-supplied variables > > injected into the code. Sed was never built to be safe for that kind of > > work. > > sed

Re: sed question

2019-12-06 Thread songbird
Greg Wooledge wrote: ... > Ideally, you'd just stop trying to use sed with user-supplied variables > injected into the code. Sed was never built to be safe for that kind of > work. sed was designed to operate on streams. a sequence of characters is a stream. i don't

Re: sed question

2019-12-06 Thread Greg Wooledge
On Fri, Dec 06, 2019 at 12:06:10PM -0500, songbird wrote: > #this doesn't work... > old_summary=`echo "Previous glitches and inconsistencies were due to a > missing / at the end of the baseurl... ,.#*$+%*$&#+(*={_})"` > result=`echo "summary: \&q

sed question

2019-12-06 Thread songbird
amp;#+(*={_})"` echo "Summary -->${old_summary}<--" result=`echo "summary: \"\"" | sed -e "s/^summary: .*$/summary: \"${old_summary}\"/"` echo -e "Result -->${result}<--\n\n" #this does work... echo -e "\n\nThis

Re: Editing Problem with bash script and sed

2017-11-18 Thread Rusi Mody
deletions, for example TrimLine.sh "College" "" > will remove College from each line in File.txt. > > After experimenting with regular expressions with sed I found ls | sed > -e s/S.*-// reduced the file names in File.txt to just the names of the > Carols

Re: Editing Problem with bash script and sed RESOLVED

2017-11-14 Thread Thomas George
with simple deletions, for example TrimLine.sh "College" "" will remove College from each line in File.txt. After experimenting with regular expressions with sed I found ls | sed -e s/S.*-// reduced the file names in File.txt to just the names of the Carols as shown in se

Re: Editing Problem with bash script and sed

2017-11-14 Thread David Wright
On Tue 14 Nov 2017 at 11:07:47 (-0500), Thomas George wrote: > The problem is editing long file names to shorten them. > An example group of file names is attached. I thought someone might mention MC for doing this. The sequence of operations I would use here is: Select the files you want to ch

Re: Editing Problem with bash script and sed

2017-11-14 Thread Greg Wooledge
On Tue, Nov 14, 2017 at 07:37:34PM +0100, Thomas Schmitt wrote: > Hi, > > after reading man 1 "read", i have to add option "-r" to my proposal: > > ls -d * | grep "$1" | while read -r filename That fixes one problem, but there are plenty more still unfixed. If the user input ("$1") is to be t

Re: Editing Problem with bash script and sed

2017-11-14 Thread Greg Wooledge
On Tue, Nov 14, 2017 at 07:21:55PM +0100, Thomas Schmitt wrote: > ls -d * | grep "$1" | while read filename Eww. No. That code is broken in multiple ways. > n=$(echo "$fname" | sed -e s/"$1"//) > > Regrettably i found no way to ma

Re: Editing Problem with bash script and sed

2017-11-14 Thread Thomas Schmitt
Hi, after reading man 1 "read", i have to add option "-r" to my proposal: ls -d * | grep "$1" | while read -r filename Have a nice day :) Thomas

Re: Editing Problem with bash script and sed

2017-11-14 Thread Thomas Schmitt
Hi, i see at least one problem in Trim_Line.sh : It uses "$1" as shell parser input and as sed regular expression. With "S.*-" as "$1", the meaning differs in both contexts. The shell parser input of for filename in *$1* will look for files with a text snippet

Re: Editing Problem with bash script and sed

2017-11-14 Thread Roberto C . Sánchez
On Tue, Nov 14, 2017 at 11:07:47AM -0500, Thomas George wrote: > > After experimenting with regular expressions with sed I found ls | sed -e > s/S.*-// reduced the file names in File.txt to just the names of the Carols > as shown in sed.txt. Used like this sed leaves the original fi

Editing Problem with bash script and sed

2017-11-14 Thread Thomas George
ach line in File.txt. After experimenting with regular expressions with sed I found ls | sed -e s/S.*-// reduced the file names in File.txt to just the names of the Carols as shown in sed.txt. Used like this sed leaves the original file unchanged. Trim_Line.sh "S.*-" ""

Re: OT: Help with sort (and maybe awk or sed)

2017-05-20 Thread rhkramer
On Saturday, May 20, 2017 09:19:07 AM Stefan Monnier wrote: > > I have a need to sort lists of URLs and associated titles formatted as > > > > follows: > >* [[][]] > > > > e.g [[http://www.google.com][Google search]] > > > > I'd like to get a simple sort routine to do that. > > In my quick

Re: OT: Help with sort (and maybe awk or sed)

2017-05-20 Thread Andre Majorel
On 2017-05-20 09:19 -0400, Stefan Monnier wrote: > > I have a need to sort lists of URLs and associated titles formatted as > > follows: > > > >* [[][]] > > > > e.g [[http://www.google.com][Google search]] > > > > I'd like to get a simple sort routine to do that. > > In my quick test, > >

Re: OT: Help with sort (and maybe awk or sed)

2017-05-20 Thread Stefan Monnier
> I have a need to sort lists of URLs and associated titles formatted as > follows: > >* [[][]] > > e.g [[http://www.google.com][Google search]] > > I'd like to get a simple sort routine to do that. In my quick test, sort -t '[' -k 4 seemed to do the trick, Stefan

OT: Help with sort (and maybe awk or sed)

2017-05-20 Thread rhkramer
the TWiki developers to reverse the order of the fields, i.e. [[][]]) is to sort on the "field" starting with "]". I don't see a way to set such a delimiter for a field in man sort, so I think I need something like awk or sed (or some other program) in addition to sort. My s

Re: When do I use perl, awk, sed, grep, cut etc.. Was[OT] get all devices from a vendor from pci.ids

2017-01-06 Thread Javier Barroso
ore ... >> >> With awk: >> awk -v vendor=0e11 'p == 1 && /^[^[:space:]]/ { p=0; } $0 ~ "^"vendor" >> " {p=1;} p' /usr/share/misc/pci.ids >> >> With sed: >> sed -ne '/^0e11/p' -e '/^0e11/,/^[^[:spac

When do I use perl, awk, sed, grep, cut etc.. Was[OT] get all devices from a vendor from pci.ids

2017-01-06 Thread Floris
quot;vendor" " {p=1;} p' /usr/share/misc/pci.ids With sed: sed -ne '/^0e11/p' -e '/^0e11/,/^[^[:space:]]/ { /^[^[:space:]]/d ; p }' /usr/share/misc/pci.ids Wrapping to script which get an argument is easy Regards Thanks for your answer, and the next question p

Re: self-encrypting drives (SED)

2015-11-22 Thread Pascal Hambourg
Pascal Hambourg a écrit : > Andrew McGlashan a écrit : >> On 22/11/2015 8:01 PM, Pascal Hambourg wrote: >>> How would a flaw in the motherboard BIOS/UEFI firmware allow to bypass >>> the disk password ? >> If it is able to snoop on your keyboard input. > > I would not call this a flaw but actual m

Re: self-encrypting drives (SED)

2015-11-22 Thread Pascal Hambourg
Andrew McGlashan a écrit : > > On 22/11/2015 8:01 PM, Pascal Hambourg wrote: >> How would a flaw in the motherboard BIOS/UEFI firmware allow to bypass >> the disk password ? > > If it is able to snoop on your keyboard input. I would not call this a flaw but actual malware.

Re: self-encrypting drives (SED)

2015-11-22 Thread Andrew McGlashan
On 22/11/2015 8:01 PM, Pascal Hambourg wrote: > Andrew McGlashan a écrit : >> >> On 22/11/2015 6:11 AM, Pascal Hambourg wrote: >>> Andrew McGlashan a écrit : > Assuming the vendor firmware has no backdoor or flaw allowing to bypass > the user-defined password. Ditto for the drive's o

Re: self-encrypting drives (SED)

2015-11-22 Thread Pascal Hambourg
Andrew McGlashan a écrit : > > On 22/11/2015 6:11 AM, Pascal Hambourg wrote: >> Andrew McGlashan a écrit : Assuming the vendor firmware has no backdoor or flaw allowing to bypass the user-defined password. >>> Ditto for the drive's own firmware. ;-) >> That's what I was referring to as "

Re: self-encrypting drives (SED)

2015-11-22 Thread Pascal Hambourg
Andrew McGlashan a écrit : > > On 22/11/2015 6:17 AM, Pascal Hambourg wrote: >> I do not see how this "solution" protects against tampering of the >> unencrypted boot part. > > True, physical access and you are still toast. The only solution I have read about to protect the boot part on the inte

Re: self-encrypting drives (SED)

2015-11-21 Thread Andrew McGlashan
On 22/11/2015 6:17 AM, Pascal Hambourg wrote: > Andrew McGlashan a écrit : > What problem does it solve exactly, besides the need of a keyboard ? > I do not see how this "solution" protects against tampering of the > unencrypted boot part. True, physical access and you are still toast. A.

Re: self-encrypting drives (SED)

2015-11-21 Thread Andrew McGlashan
On 22/11/2015 6:11 AM, Pascal Hambourg wrote: > Andrew McGlashan a écrit : >>> Assuming the vendor firmware has no backdoor or flaw allowing to bypass >>> the user-defined password. >> >> Ditto for the drive's own firmware. ;-) > > That's what I was referring to as "vendor firmware". The disk ve

Re: self-encrypting drives (SED)

2015-11-21 Thread Pascal Hambourg
es not protect against tampering, as the boot >>> part cannot be encrypted. >> >> As I understand it, self-encrypting drives (SED) encrypt >> everything (including the boot partition). > > You can do full disk enccryption, but you are right that you need > somethi

Re: self-encrypting drives (SED)

2015-11-21 Thread Pascal Hambourg
Andrew McGlashan a écrit : > > On 21/11/2015 8:17 PM, Pascal Hambourg wrote: >> David Christensen a écrit : >>> As I understand it, self-encrypting drives (SED) encrypt everything >>> (including the boot partition). To use this feature, you need a >>> co

Re: self-encrypting drives (SED)

2015-11-21 Thread Andrew McGlashan
On 21/11/2015 8:17 PM, Pascal Hambourg wrote: > David Christensen a écrit : >> >> As I understand it, self-encrypting drives (SED) encrypt everything >> (including the boot partition). To use this feature, you need a >> computer with BIOS/ UEFI that supports it -

Re: self-encrypting drives (SED)

2015-11-21 Thread Andrew McGlashan
tampering, as the boot >> part cannot be encrypted. > > As I understand it, self-encrypting drives (SED) encrypt > everything (including the boot partition). You can do full disk enccryption, but you are right that you need something to "boot" ... my solution is to use dro

Re: self-encrypting drives (SED)

2015-11-21 Thread hdv
and read or modify it with another >> machine. >> >> To protect against this you can use encryption or set up a password >> on the disk (ATA security functions). Note that encryption alone does >> not protect against tampering, as the boot part cannot be encrypted. &

Re: self-encrypting drives (SED)

2015-11-21 Thread Pascal Hambourg
David Christensen a écrit : > > As I understand it, self-encrypting drives (SED) encrypt everything > (including the boot partition). To use this feature, you need a > computer with BIOS/ UEFI that supports it -- e.g. the BIOS will prompt > you for the password during POST; if

self-encrypting drives (SED)

2015-11-20 Thread David Christensen
use encryption or set up a password on the disk (ATA security functions). Note that encryption alone does not protect against tampering, as the boot part cannot be encrypted. As I understand it, self-encrypting drives (SED) encrypt everything (including the boot partition). To use this feature

sed, insert file before last line

2014-07-11 Thread T o n g
Hi, The following inserting file method for sed used to be working, even before last line, but not any more. Is it a bug in the current sed? Demo of inserting file method with sed: mkdir /tmp/test printf '%s\n' {1..3} > /tmp/test/f1 printf '%s\n' {one,two,three,four,fi

Re: Please help parsing file [sed, awk, fortran, bash]

2012-09-01 Thread Alois Mahdal
On Thu, 30 Aug 2012 21:44:04 -0400 "John L. Cunningham" wrote: > Hi Daniel, > > Here's my awk solution: > [snip] Very nice, this should be added as an example to an awk-learning document :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trou

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Gaël DONVAL
As usual, I obviously screwed up the indexes... > 10 DAT(IDX)=VAL < 10 DAT(IDX+1)=VAL > WRITE(2,*), i, DAT(i) < WRITE(2,*), i-1, DAT(i) Le vendredi 31 août 2012 à 20:00 +0200, Gaël DONVAL a écrit : > I have to learn fortran. > I just thought this was

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Gaël DONVAL
understood but your coworker might not have realized that). > I will be looking into sed as it seems like a really useful tool. I have not used sed enough to be fully proficient with it but while I think replacing missing values might be quite easy, I can't come up with something to expand t

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread daniel jimenez
arbitrarily (maybe the photon counter outputs that, no clue [dont really care]) and Im doing this as a favor. I will be looking into sed as it seems like a really useful tool. many thanks to all for your inputs p.s. doing this from fortran would be a chore... On Fri, Aug 31, 2012 at 7:58 AM, Gaël DONVAL

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Gaël DONVAL
Le vendredi 31 août 2012 à 09:48 -0400, Miles Fidelman a écrit : > For going through a file, line-by-line, and massaging the format, my > first instinct would be sed. That's what it's intended for. Actually, I did not read the whole thread (shame on me) prior to answering.

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Miles Fidelman
would suggest python is a much better choice to a young person just starting out. For going through a file, line-by-line, and massaging the format, my first instinct would be sed. That's what it's intended for. Miles Fidelman -- In theory, there is no difference between theory an

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Gaël DONVAL
Le vendredi 31 août 2012 à 09:46 +0100, Jon Dowland a écrit : > On Fri, Aug 31, 2012 at 02:18:15AM +, Mark Blakeney wrote: > > On Fri, 31 Aug 2012 01:31:29 +, Russell L. Harris wrote: > > > This exercise provides the impetus to learn to use a very useful tool, > > > namely Perl. > > > > I

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Jon Dowland
read ignore read ignore index=-1 while read line; do set -- $line index=$((index + 1)) if [ $index != "$1" ]; then while [ $(($1 - $index)) -gt 0 ]; do echo $index 0 index=$((index + 1)) done fi index="$1" [ "$index" -le 1024 ] || break second=1 shift [ $# -le

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Jon Dowland
On Fri, Aug 31, 2012 at 02:18:15AM +, Mark Blakeney wrote: > On Fri, 31 Aug 2012 01:31:29 +, Russell L. Harris wrote: > > This exercise provides the impetus to learn to use a very useful tool, > > namely Perl. > > I would suggest python is a much better choice to a young person > just star

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-31 Thread Morel Bérenger
hich would just > obfuscate my code unnecessarily. > > 3 apart from R code, I'm not used to object oriented oriented programming > and I have only done bash for scripting. I read a bit of the usefulness > of perl, awk and sed a while ago but I haven't had the time to get in

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread daniel jimenez
ogramming and I have only done bash for scripting. I read a bit of the usefulness of perl, awk and sed a while ago but I haven't had the time to get into that yet. 4 I thought reading someone's suggestions (and retyping the proposed code) on this task would be a nice way of learning a

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread lina
On Friday 31,August,2012 11:22 AM, Richard Owlett wrote: > lina wrote: >> On Friday 31,August,2012 08:35 AM, Richard Owlett wrote: >>> daniel jimenez apparently described a *HOMEWORK* problem: Hello all, I need some help fixing the format of some pretty strangely compressed data

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread Richard Owlett
lina wrote: On Friday 31,August,2012 08:35 AM, Richard Owlett wrote: daniel jimenez apparently described a *HOMEWORK* problem: Hello all, I need some help fixing the format of some pretty strangely compressed data files. An example would be like this: 2883 452 07 16 2 4 6 107 Parsing rules:

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread lina
On Friday 31,August,2012 08:35 AM, Richard Owlett wrote: > daniel jimenez apparently described a *HOMEWORK* problem: >> Hello all, >> >> I need some help fixing the format of some pretty strangely >> compressed data files. An example would be like this: >> >> 2883 >> 452 >> 07 >> 16 >> 2 >> 4 >> 6

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread Mark Blakeney
On Fri, 31 Aug 2012 01:31:29 +, Russell L. Harris wrote: > This exercise provides the impetus to learn to use a very useful tool, > namely Perl. I would suggest python is a much better choice to a young person just starting out. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.o

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread John L. Cunningham
7;. >If there the index skips (ex. from index=2 to index=4), then the indexes >which where skipped should be set to '0' > Max index is 1024. >That is it. I'd like to be guided to an app (scripting language? awk? sed? >I haven't used those so I rea

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread Russell L. Harris
* Richard Owlett [120831 00:39]: > daniel jimenez apparently described a *HOMEWORK* problem: ... > >I need some help fixing the format of some pretty strangely > >compressed data files. An example would be like this: This exercise provides the impetus to learn to use a very useful tool, namely Pe

Re: Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread Richard Owlett
4. That is it. I'd like to be guided to an app (scripting language? awk? sed? I haven't used those so I really don't know where to start) that can help me do that effectively. The command, with the script possibly as the argument, is to be included in a bash script right befo

Please help parsing file [sed, awk, fortran, bash]

2012-08-30 Thread daniel jimenez
x27;. If there is no second number (ex. index=2), then the second number should be set to '1'. If there the index skips (ex. from index=2 to index=4), then the indexes which where skipped should be set to '0' Max index is 1024. That is it. I'd like to be guided to an app

Re: [1/2OT] something about sed

2012-02-27 Thread lina
On Monday 27,February,2012 04:49 PM, Bob Proulx wrote: lina wrote: Bob Proulx wrote: Lina, I am dissappointed and hurt that my messages aren't of high enough quality to make the cut for your reading. What may I do to improve them? :-) Oh Bob, I am terribly wrong (haha ... I am kidding here.

Re: [1/2OT] something about sed

2012-02-27 Thread Bob Proulx
lina wrote: > Bob Proulx wrote: > >Lina, I am dissappointed and hurt that my messages aren't of high > >enough quality to make the cut for your reading. What may I do to > >improve them? :-) > > Oh Bob, I am terribly wrong (haha ... I am kidding here. gotta be > serious. please don't be disappoi

Re: [1/2OT] something about sed

2012-02-26 Thread lina
On Monday 27,February,2012 03:45 AM, Bob Proulx wrote: lina wrote: Javier Barroso wrote: or using extended regular expressions, you can remove all escape stuff : sed -re 's/([^ ]+)( +)([^ ]+)/\3\2\1/g' Ha ... I didn't realize the -r can be used. sed -re 's/([^ ]+) ([^ ]+

Re: [1/2OT] something about sed

2012-02-26 Thread Bob Proulx
lina wrote: > Javier Barroso wrote: > >or using extended regular expressions, you can remove all escape stuff : > >sed -re 's/([^ ]+)( +)([^ ]+)/\3\2\1/g' > > Ha ... I didn't realize the -r can be used. > > sed -re 's/([^ ]+) ([^ ]+) ([^ ]+)/\3 \2 \

Re: [1/2OT] something about sed

2012-02-26 Thread lina
On Monday 27,February,2012 12:16 AM, Allan Wind wrote: On 2012-02-26 23:30:55, lina wrote: $ echo "GNU linux is cool" | sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' GNU linux is cool What is it that you are trying to do? The regex is looking for It&

Re: [1/2OT] something about sed

2012-02-26 Thread lina
On Monday 27,February,2012 12:14 AM, Javier Barroso wrote: On Sun, Feb 26, 2012 at 4:30 PM, lina wrote: Hi, sorry a bit off-topic, sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' GNU Linux is cool Linux GNU cool is No here ... I don't know why $ echo &quo

Re: [1/2OT] something about sed

2012-02-26 Thread Allan Wind
On 2012-02-26 23:30:55, lina wrote: > $ echo "GNU linux is cool" | sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ > ]*>\)/\3\2\1/g' > GNU linux is cool What is it that you are trying to do? The regex is looking for optional space and as there are no <> in

Re: [1/2OT] something about sed

2012-02-26 Thread Javier Barroso
On Sun, Feb 26, 2012 at 4:30 PM, lina wrote: > Hi, > > sorry a bit off-topic, > > sed -e 's/\(<[^ ]*>\)\([ ]*\)\(<[^ ]*>\)/\3\2\1/g' > GNU Linux is cool > Linux GNU cool is No here ... > > I don't know why > > $ echo "GNU linu

  1   2   3   4   5   6   >