Reputation
2,078
Top tag
Next privilege 2,500 Rep.
Create tag synonyms
Badges
4 13
Impact
~43k people reached

  • 0 posts edited
  • 1 helpful flag
  • 43 votes cast
4m
comment Mixup between root and first non-root user account
What's the numerical user ID for "jerome" (i.e., the third field in the line in /etc/passwd that starts with "jerome:")?
Mar
9
comment Not getting grep with a variable
Hint 1: Count your parentheses. Hint 2: The $(echo part is pointless; n=$(( (RANDOM%6) +1)) is sufficient. Hint 3: A pipe | creates child processes that run essentially in parallel. Do you think it makes sense to execute these two commands in parallel?
Dec
10
awarded  Citizen Patrol
Nov
23
answered regex - Searching for only character pairs
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 <>