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

Nov
5
answered How to see manpage of previous command?
Nov
1
revised Match a whole word (IP address) using `sed`
added 5 characters in body
Nov
1
revised Match a whole word (IP address) using `sed`
Added sed solution using extended regexps
Nov
1
comment Match a whole word (IP address) using `sed`
@terdon The original question is unclear. Essentially, the OP asks two questions that should have different solutions. After the example, he says that he wants to match No. 1, 2, 4, 6, 7, 8, 9 (where 1.2.3.4 is potentially preceded or followed by a letter), but not 3 and 5 (where 1.2.3.4 is preceded or followed by a number, resulting in a different IP). So it seems that iaaNEWIPad (from No. 4) is indeed an expected result. If not, the OP should make his question more precise.
Nov
1
revised Match a whole word (IP address) using `sed`
perl solution added
Nov
1
revised Match a whole word (IP address) using `sed`
deleted 2 characters in body
Nov
1
answered Match a whole word (IP address) using `sed`
Oct
31
answered get parts of string using shell script
Oct
29
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.
Oct
29
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.
Oct
29
comment How do I remove every number that's surrounded by <>
@Floegipoky thanks, answer updated.
Oct
29
revised How do I remove every number that's surrounded by <>
first sentence changed; slurp mode added
Oct
28
revised How do I remove every number that's surrounded by <>
explanation added
Oct
28
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.
Oct
28
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.
Oct
28
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?