Tagged Questions
8
votes
6answers
256 views
Delete lines beginning with #
How do I delete lines beginning with a #, given that there can be whitespace on the left and right of the #?
# Master socket provides access to userdb information. It's typically
2
votes
1answer
106 views
How to insert a first column to many files + how to convert unix time to normal time
There are many-many files in a directory that has e.x.: the following content:
INPUT:
root 1324711901
sshd 1272725792
And I'm searching for a solution how to convert the content of the ...
4
votes
4answers
223 views
How can I remove a specific string from a file only if there are other lines in the file?
How can I remove a specific string from a file ONLY if there are other lines in the file?
For example, don't touch this file:
cat file.txt
ASDF
but remove "ASDF" from this file:
cat file.txt
ASDF
...
1
vote
1answer
283 views
How to convert <a href=“http://xy.com”>XY</a> to [http://xy.com XY]?
Just for editing Wiki's..
So i have this input [from a larget text]:
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT BLA-BLA RANDOMSTRINGS BLA-BLA
TEXT TEXT <a ...
3
votes
4answers
159 views
Replacing text from a list of replacements. Added complication: backslashes
I have a file A that contains pairs of strings, one per line:
\old1 \new1
\old2 \new2
.....
I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
6
votes
5answers
570 views
Is there any alternative to grep's -A -B -C switches (to print few lines before and after )?
grep -A 2 -B 3
prints 2 lines after the grep string and prints 3 lines before.
grep -C 3
prints 3 Lines before and 3 lines after
Unfortunately, the grep I'm using does not support these ...
5
votes
1answer
161 views
Is there a way to make perl -i not clobber symlinks?
A friend of mine points out that if you do:
perl -pi.bak -e 's/foo/bar/' somefile
when "somefile" is actually a symlink, perl does just what the docs say it will do:
It does this by renaming ...