1,922 reputation
412
bio website mpi-inf.mpg.de/~uwe
location
age
visits member for 2 years, 1 month
seen 49 mins ago

1d
comment How do I remove every number that's surrounded by <>
@mikeserv Sure, it's the same difference as between a global substitution s/.../.../g and a repeated single substitution. In theory, we can always simulate the former by the latter, provided that we introduce some temporary marking characters that prevent us from replacing the same string over and over again. In practice, we prefer to avoid that. Tasks like "append a zero to every number within <>" or "replace all zeros by ones and vice versa within <>" are easily solved with nested substitutions; with explicit loops they are not.
1d
comment How do I remove every number that's surrounded by <>
@mikeserv You're right, in this particular case, a simple loop arond the substitution is sufficient. I hadn't thought about this approach when I wrote the (former) first sentence. For other"replace this by that, but only in the following context" problems, the loop method can get very nasty.
1d
comment How do I remove every number that's surrounded by <>
@Floegipoky thanks, answer updated.
1d
revised How do I remove every number that's surrounded by <>
first sentence changed; slurp mode added
2d
revised How do I remove every number that's surrounded by <>
explanation added
2d
comment How do I remove every number that's surrounded by <>
If you want to modify the input file, you can use the -i option as in sed, i.e., perl -i -pe 'PERLCOMMANDS' inputfile. Without the -i option, the modified contents are written to standard output.
2d
comment How do I remove every number that's surrounded by <>
Note that this works only if there is at most one sequence of digits within <...>. For <a1b>, it works, for <a1b2>, it doesn't. You need a loop within sed, if you want to handle the latter case.
2d
answered How do I remove every number that's surrounded by <>
Oct
24
comment How do I use the “if” command for multiple conditions?
@DisplayName Still the question is whether there can be several files, say town-1.swf and town-2.swf? (If it's impossible, there's an easy solution; if it's possible, you have to work harder.)
Oct
24
comment How do I use the “if” command for multiple conditions?
@DisplayName Just for clarification: Do you assume that there is at most one file matching each of the patterns town-*.swf and city-*.swf, or could there be several ones?
Oct
24
comment How do I use the “if” command for multiple conditions?
@ryekayo case can (and often should) be used for testing equality or matching, but how do you want to use case to check whether a file exists?
Oct
24
answered How to remove file with mv command?
Oct
21
comment Inserting the “∃” character into a text field
So the application is working with UTF-8, and probably the X server as well. Perhaps there's a problem with xbindkeys or xvkbd. I'd try one of the other methods explained in unix.stackexchange.com/questions/134473/…
Oct
21
revised Inserting the “∃” character into a text field
corrected spelling
Oct
21
answered Inserting the “∃” character into a text field
Oct
21
comment Print a line in stdout that matches an expression if the output contains another expression
@Jidder /^$/{if(a==1) print b; a=0} starts a new block. The input file for the awk script consists of several blocks separated by blank lines, and the src: line should be printed whenever the corresponding block contains foo. The /:.* "foo"/ pattern checks for "foo" somewhere after the colon in the line. The begin block is just for clarity, but yes, it's redundant.
Oct
20
revised Print a line in stdout that matches an expression if the output contains another expression
added 521 characters in body
Oct
20
comment Print a line in stdout that matches an expression if the output contains another expression
ok, answer updated.
Oct
20
revised Print a line in stdout that matches an expression if the output contains another expression
deleted 198 characters in body
Oct
20
comment Print a line in stdout that matches an expression if the output contains another expression
And the outputs are separated by what? Blank lines? Or does every src: start a new block?