New answers tagged sed
0
votes
sed option to preserve file times during a find/replace?
You could use a mix of sed -i and touch, to preserve the initial timestamp. For example:
file=file-to-edit
sed -i .bak 's|...' "$file"
touch -r "$file.bak" "$file"
# rm &...
1
vote
keep each line containing x only if column y is the first containing x. remove the rest containing x
So, I went this route, which is nice and simple and seems to be working for me:
awk -F, '!x[$4]++'
A far as I can tell, awk here is checking the 4th column (field), if it's not seen it before, then ...
0
votes
Accepted
sed remove with regex
I was able to do this with the following!
for f in src/**/*.c
do
sed -i '/#ifdef CEEDLING_TESTS/d' $f
sed -i '/#else/,/#endif/d' $f
done
0
votes
sed: how to replace line if found or append to end of file if not found?
As a programmer not accustomed to shell scripts it was easier to construct a more readable (for me) command by first deleting any existing match and then appending the value to the end of file
my-...
Top 50 recent answers are included
Related Tags
sed × 974linux × 341
bash × 337
awk × 224
regex × 172
command-line × 135
grep × 111
unix × 77
shell × 60
shell-script × 41
find-and-replace × 38
perl × 38
macos × 36
text-editing × 30
bash-scripting × 29
script × 27
find × 22
vim × 21
csv × 21
windows × 20
ubuntu × 17
cygwin × 14
string-manipulation × 13
terminal × 11
rename × 11