Tag Info

New answers tagged

0

If scp were working, then you'd be able to run this: scp remotehost:/path/to/remote/file /dev/stdout


2

cat /dev/null is a no op as it outputs exactly nothing. A simpler way to blank a file's content is then to redirect the null command to it that way: : > file or even, with most shells, only use a redirection without specifying any command: > file The fact the reported size by ls is still high is just due by the writing process seeking to the ...


3

Assuming you meant to say cat /dev/null > file_log.txt the answer is that the process that has the file open for writing did so without O_APPEND, or it sets the offset into the file arbitrarily, in which case a sparse file is created. This is a file that contains "holes", i.e. the system "knows" that there are large regions with zeroes, which are not ...


2

cat /dev/null file_log.txt This only made cat read /dev/null and immediately read file_log.txt and output the result to stdout, your screen. This won't delete anything, at all. If you want to test out, use cat /dev/null non_existent_file and you will see that it errors out. The correct way to truncate a file, is using shell redirectors or any kind of ...


3

Curl can display the file the same way cat would. No need to delete the file since it simply displayed the output unless you tell it to do otherwise. curl -u username:password sftp://hostname/path/to/file.txt If you use public key authentication: curl -u username: --key ~/.ssh/id_rsa --pubkey sftp://hostname/path/to/file.txt If you use the default ...


0

egrep -v ^'(#|$)' file.txt Strips all comments and empty lines from file.txt


4

Isn't cat reading from the stdin and stores that that into file "filename"? Yes, when cat does not have any filename arguments (or if one of the files is the minus character -), it reads from stdin. Perhaps use of the word "never" by the book is a bit misleading, because: Is the above excerpt from the book just saying that only the particular form ...


0

This may not help, but here's a similar problem I've had in the past. When I cat the device file for my mouse directly (i.e., using cat /dev/input/by-id/usb-<mymouse>) I get output similar to what you get with your keyboard (i.e., gibberish). However, some mouse motions, like left click, don't generate any printable characters, so the terminal shows ...


1

Here is a similar question from stackoverflow http://stackoverflow.com/questions/5893531/fast-concatenate-multiple-files-on-linux The simple answer is this- It could only work if all the files (except the last) were guaranteed to have a size that is a multiple of the filesystem's block size. Because the filesystem needs to read through all the blocks ...


5

The largest obstacle to a tool like this existing is that unless each file's size (except the last one) being concatenated is exactly divisible by the block size (I'm a little uncertain about the right terminology here), you'll end up with "gaps" with garbage data between your concatenated files in the final file. This is because file data is typically ...


1

No way to recover, as simple as that. As a side note, doing dd is not a perfect way to backup files. For future cases, consider using tools like dar - you want some compression, incremental backup would also allow you to save huge amount of time and disk space in most cases.


4

If you do not have backups, your data wasn't important. It's gone. There is no undo. Especially not with encryption involved. something that produces output > /dev/somedisk overwrites data on the device. Whatever is overwritten can not be restored, so your only chance would be if you noticed and cancelled it right away. Then probably only the first few ...


0

If by .out you mean the binary executable files on linux then probably you will have to learn the eLF file format of linux to find the size of header and the using head you can concatenate the header of the file.


1

To concatenate files cat file1 file2 file3 > output To get the first N lines of a file head -n N file To get the first N lines of file1 and then concatenate all the other files head -n N file | cat - file1 file2 file3 > output Cat will read standard input from the piped command (- argument) and concatenate it with the specified files. See ...


4

The curses program tabs will allow you to change what the terminal believes to be the width of a ^I. This would make a simple script tabs -4 cat "$@" tabs -8 However, the processing of tab characters on terminals is notoriously wonky and I'm of the impression that you should never mess with them. I suggest using expand as in: expand -4 "$@" which is ...


7

There's an app for that! $ cat file1 file1 line1 file1 line2 $ cat file2 file2 line1 file2 line2 Now, if you pass these files as arguments to paste: $ paste -d' ' file1 file2 file1 line1 file2 line1 file1 line2 file2 line2 If by "file1 1st line followed by file2 first line, and file1 second line followed by file2 second line etc.", you mean that you ...



Top 50 recent answers are included