Tag Info

New answers tagged

1

According to the docs, busybox 1.12.1 has vi. Anyway, here's your sed regex: sed -i "s/filter\ \=\ \[\ \"a\/loop2\/\",\ \"r\/\.\*\/\"\ \]/filter = [ \"a\/.*\/\" ]/" /etc/lvm/lvm.conf


0

You can also distribute the file stream with tee and then split in parallel: <file tee >(grep '^foo' > foo.txt) >(grep '^bar' > bar.txt) > /dev/null Result: $ tail -n+1 foo.txt bar.txt ==> foo.txt <== foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz ==> bar.txt <== bar xxx yyy zzz bar xxx yyy ...


1

awk '{ f = $1 ".txt"; print > f }' file


1

grep ^foo input.txt > foo.txt grep ^bar input.txt > bar.txt ^ will make sure you only match the beginning of the line, so it will work even if the rest of the line looks like: foo xxx yyy zzz bar


1

Try this code, and make any chages if need since i have not tried to run it. awk ' BEGIN { foo="foo.txt"; bar="bar.txt" } {if ($1 == "foo") $0 >> foo; else $0 >> bar; }' sourcefilename


4

grep -E '^foo' input.txt > foo.txt grep -E '^bar' input.txt > bar.txt mbp-000234:~ dmourati$ cat foo.txt foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz foo xxx yyy zzz mbp-000234:~ dmourati$ cat bar.txt bar xxx yyy zzz bar xxx yyy zzz


1

When you run the ./myApp &>myApp.log command output is redirected to a new file with the filename myApp.log. When you run your sed -i "1,200d" myApp.log command a new file is created with the name myApp.log. The problem here is that the original command is still writing to the file that was original created, but which has been unlinked and no longer ...


3

When a file is opened, the system assigns a file descriptor to it. While the file is open, it is accessed via this FD. When you run the sed command it truncates the file by copying it to a new file. You can see this because the inode number changes ls -i log 131122 log sed -i "1,200d" log ls -i log 131090 log What's happening is that the file is being ...


1

Your sed command will create a new file and write the processed output to that file. Then it will rename the new file to replace the old file. The process will still be writing to the same file you redirected the output to at first. The file is now deleted, but that doesn't prevent a process which has the file open from writing to it. You should start ...



Top 50 recent answers are included