Tag Info

Hot answers tagged


Try the watch command. Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=<n>] [--no-title] [--version] <command>` So that: watch -n1 command will run the command every second, forever. On Mac OS X, you can get watch from Mac Ports, or you can get it via Homebrew: brew install watch


The old-style backquotes ` ` do treat backslashes and nesting a bit different. The new-style $() interprets everything in between ( ) as a command. echo $(uname | $(echo cat)) Linux echo `uname | `echo cat`` bash: command substitution: line 2: syntax error: unexpected end of file echo cat works if the nested backquotes are escaped: echo `uname | \`echo ...


There are lots of options!!! Summary $ echo $((20.0/7)) $ zcalc $ bc <<< 20+5/2 $ bc <<< 'scale=4;20+5/2' $ expr 20 + 5 $ calc 2 + 4 $ node -pe 20+5/2 # Uses the power of JavaScript, e.g. : node -pe 20+5/Math.PI $ echo 20 5 2 / + p | dc $ echo 4 k 20 5 2 / + p | dc $ perl -E "say 20+5/2" $ python -c "print 20+5/2" $ python -c "print ...


sudo touch /bin/rm && sudo chmod +x /bin/rm apt-get download coreutils sudo dpkg --unpack coreutils* And never again. Why didn't you use sudo with apt-get? Because the download command doesn't require it: download download will download the given binary package into the current directory. So, unless you are ...


Don't go straight to du /. Use df to find the partition that's hurting you, and then try du commands. One I like to try is du -h <dir> | grep '[0-9\.]\+G' because it prints sizes in "human readable form". Unless you've got really small partitions, grepping for directories in the gigabytes is a pretty good filter for what you want. This will ...


More precisely, a double dash (--) is used in bash built-in commands and many other commands to signify the end of command options, after which only positional parameters are accepted. Example use: lets say you want to grep a file for the string "-v" - normally "-v" will be considered the option to reverse the matching meaning (only show lines that do not ...


I'd strongly suggest not to use find -L for the task (see below for explanation). Here are some other ways to do this: If you want to use a "pure find" method, it should rather look like this: find . -xtype l (xtype is a test performed on a dereferenced link) This may not be available in all versions of find, though. But there are other options as ...


Try out multitail. This is an übergeneralization of tail -f. You can watch multiple files in separate windows, highlight lines based on their content, and more. multitail -c /path/to/log The colors are configurable. If the default color scheme doesn't work for you, write your own in the config file. For example, call multitail -cS amir_log /path/to/log ...


One of the following 2 should work: $ nohup redshift & or $ redshift & $ disown See the following for a bit more information on how this works: man nohup help disown Difference between nohup, disown and & (be sure to read the comments too)


Use "--" to make rm stop parsing command line options, like this: rm -- --help


For GNU gzip 1.6 or above, FreeBSD and derivatives or recent versions of NetBSD, see don_cristi's answer. With any version, you can use shell redirections as in: gzip < file > file.gz When not given any argument, gzip reads its standard input, compresses it and writes the compressed version to its standard output. As a bonus, when using shell ...


debian and its derivatives (and probably most other distributions) come with busybox which is used in the initramfs. busybox bundles most core command line utilities in a single executable. You can temporarily symlink /bin/rm to /bin/busybox: ln -s busybox /bin/rm To get a working rm (after which you can do your apt-get install --reinstall coreutils). ...


This expands somewhat on the !! trick mentioned in this answer. There are actually a bunch of history-related commands that tend to get forgotten about (people tend to stab Up 100 times instead looking for a command they know they typed). The history command will show a list of recently run commands with an event designator to the left !N will substitute ...


You want to be using GNU Screen. It is super awesome! ssh me@myserver.com screen #start a screen session run-a-long-process CTRL+a , d to detatch from your screen session exit #disconnect from the server, while run-a-long-process continues When you come back to your laptop: ssh me@myserver.com screen -r ...


Use nohup to make your process ignore the hangup signal: $ nohup long-running-process & $ exit


If you're just switching between two directories, you can use cd - to go back and forth.


Your shell is meant to evaluate that shell code output by ssh-agent. Run this instead: eval "$(ssh-agent)" Or if you've started ssh-agent already, copy paste it to your shell prompt (assuming you're running a Bourne-like shell). ssh commands need to know how to talk to the ssh-agent, they know that from the SSH_AUTH_SOCK environment variable.


Bash: shopt -s autocd Zsh: setopt autocd tcsh: set implicitcd Also, 'autojump' is a useful tool. Once installed it remembers directories so that you can type j abc and if you've visited abc before, say x/d/f/g/t/abc then it will cd to there! https://github.com/joelthelion/autojump


If you have GNU coreutils (common in most Linux distributions), you can use du -sh * | sort -h. The -h option tells sort that the input is the human-readable format (number with unit). This feature was added to GNU Core Utilities 7.5 in Aug 2009.


Because they didn't exist originally, and the default behavior is backwards compatible. Also, because they don't exist on all unix variants, and the default behavior is compatible with other unix variants. For many tools, because they are intended to be parseable by other tools. This is rarely the case for ls, but parsing the output of du or df is ...


There's no built-in command, but you can easily write a function that calls mkdir then cd: mkcd () { mkdir "$1" cd "$1" } Put this code in your ~/.bashrc file (or ~/.kshrc for ksh users, or ~/.zshrc for zsh users). It defines a function called mkcd. "$1" will be replaced by the argument of the function when you run it. This simple version has several ...


You can use tee and process substitution for this: cat file.txt | tee >(pbcopy) | grep errors This will send all the output of cat file.txt to pbcopy, and you'll only get the result of grep on your console. You can put multiple processes in the tee part: cat file.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep errors


The difference is in what data the target program is accepting. If you just use a pipe, it receives data on STDIN (the standard input stream) as a raw pile of data that it can sort through one line at a time. However some programs don't accept their commands on standard in, they expect it to be spelled out in the arguments to the command. For example touch ...


On *BSD: date -r 1234567890 On Linux (specifically, with GNU coreutils ≥5.3): date -d @1234567890 With older versions of GNU date, you can calculate the relative difference to the UTC epoch: date -d '1970-01-01 UTC + 1234567890 s' If you need portability, you're out of luck. The only time you can format with a POSIX shell command (without doing the ...


Yes. The standard grep tool for searching files for text strings can be used to subtract all the lines in one file from another. grep -F -x -v -f fileB fileA This works by using each line in fileB as a pattern (-f fileB) and treating it as a plain string to match (not a regular regex) (-F). You force the match to happen on the whole line (-x) and print ...


bash -- insert preceding line's final parameter alt-. the most useful key combination ever, try it and see, for some reason no one knows about this one. press it again and again to select older last parameters. great when you want to do something more to the argument/file you used just a moment ago.


Typically one uses tar to create an uncompressed archive and either gzip or bzip2 to compress that archive. The corresponding gunzip and bunzip2 commands can be used to uncompress said archive, or you can just use flags on the tar command to perform the uncompression. If you are referring specifically to the Zip file format, you can simply use the zip and ...

Only top voted, non community-wiki answers of a minimum length are eligible