New answers tagged cat
After doing a bit more research I realised that this scenario is exactly what xargs is designed for: ./my-command args | cut -d : -f 5 | xargs cat Which will transform the output of stdin into an invocation of cat with an actual filename and thus print out the file contents
You don't need the cat. sed happily accepts the file name as argument: sed 's/^ *//' <file> If you use GNU sed you can use the -i or --in-place switch to edit the file in place: sed -i 's/^ *//' <file> To answer the question, you can achieve “full file buffering” using the tool sponge from the moreutils package. Using sponge you can do: ...
Useless use of the cat command. Use sed directly to print the contents or use -i to do an in place edit.
One other possibility is to put the entire contents of a file into a shell variable. There used to be a limit on the size, but I understand that this is no longer a problem. As long as you have the memory (of course exceeding physical memory would cause swapping) you can try the following: For example: varx=`cat filename` echo "$varx" | sed ..... ...
Have you looked at the Linux buffer command? This utilizes a user shared memory segment to basically allow concurrent reads/writes. I suppose that it could buffer an entire file if the shared memory segment is large enough. The buffer command might not be automatically installed, but I have found the program in many of the repositories on different Linux ...
You simply have to use -i switch of (GNU) sed, so sed -i -r 's/^ *//' file_to_replace_in_place.txt and for Os X : sed -i.'' -r 's/^ *//' file_to_replace_in_place.txt Another (more generic) solution is to use tee : cat file | sed 's/^ *//' | tee file you have to take care of huge files, this can exit without error, nor change.
Top 50 recent answers are included