46 Actions

How to filter some files out of my directory?Also maybe worth noting that the -- tells mv that there will be no further options (thus you can rename a file called -foo with mv -- -foo bar). This means that, in general, you should use -- in scripts; it also means that it's not necessary in this case, because mv will only ever get passed filenames that start with a number.

How to filter some files out of my directory?You don't need zmv; you can setopt extended_glob and use that same glob pattern with plain mv (or any other program, for that matter). Personally, I would use mv with the -t option.

How to store a large folder in a single file without compressionIt's worth noting the way to avoid making the archive with absolute paths: tar -cf $archive.tar -C $source_dir .. If the destination machine doesn't have directory with the same path as the source directory, you'll need to do that. Just make sure to -C into a new directory when you extract (mkdir $destination_dir && tar -xf $archive.tar -C $destination_dir); else the archive contents will get dumped into whatever directory you happen to be in.

Location of the crontab fileThe corollary of this answer is that one should redirect the output of crontab -l to a file, move the file to the other system, and pipe it to crontab. Or maybe even do it directly (crontab -l | ssh $remote_host crontab).

How to find executable filetypes?The binaries I sampled from my Mac are application/octet-stream; charset=binary, according to both the Mac's file and the file on my Debian box. (Speaking of OS X, the file it includes uses -I instead of -i. Both accept --mime, though.)

Feb10

comment

Why can't I do ls *.txt in a subshell?Note that double quotes (at least in bash and similar shells like zsh) are not the same as single quotes! For example, parameter expansion ($foo) is done inside double quotes, but not single quotes.

What's eating my disk space?I prefer ncdu over plain du for finding large files|directories. It does scan the entire directory tree before it lets you do anything; you may want to pass it a specific path (e.g. ncdu /var or even just ncdu ~)

Feb5

comment

How can I delete input in the terminal?@terdon Fair enough. I just found it misleading; I would interpret send a process to the background as make a process continue running in the background. According to the image, control-pageup and control-pagedown are supposed to “scroll the terminal, even remote or graphical ones.”