Tag Info

Hot answers tagged

36

lynx has a "dump" mode, which you can use with watch: $ watch lynx https:/www.google.com -dump From man lynx: -dump dumps the formatted output of the default document or those specified on the command line to standard output. Unlike interactive mode, all documents are processed. This can be used in the ...


15

Because builtins are part of the shell. Any bugs or history they have are bugs and history of the shell itself. They are not independent commands and don't exist outside the shell they are built in. The equivalent, for bash at least, is the help command. For example: $ help while while: while COMMANDS; do COMMANDS; done Execute commands as long as a ...


11

You can use the at command: $ sudo at 6:45 [sudo] password for root: warning: commands will be executed using /bin/sh at> poweroff at> <EOT> Don't type the <EOT>, but press Ctrl+D at the second at> prompt.


9

You can use shutdown: sudo shutdown -h 06:45 & And to check it: ps -aux | grep shutdown If you want to cancel it: sudo killall shutdown This assumes of course that the shutdown time has already passed.


8

If you are using bash: shopt -s extglob rm !(file1|file2|file3) After bash manual: !(pattern-list) matches anything except one of the given patterns and pattern-list is a list of one or more patterns separated by a |.


7

The changes you've made to PATH are likely temporary. Close the shell you're in with exit and reopen it. In the event that you have edited a file that sets the PATH for newly opened shells, specify the full path to commands to fix whatever you've changed (eg. /usr/bin/vim).


7

Reset your path right now with: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin It doesn't get your full PATH restored but basic utilities will be available again. Here's what probably happened: You had a PATH variable (referred to as $PATH when reading from it) Something like: $ echo $PATH ...


7

w3m is another program that has a --dump option. It is the backend Emacs' most popular web browser.


7

Use a format: $ seq -f "10.20.30.%g" 40 50 10.20.30.40 10.20.30.41 10.20.30.42 10.20.30.43 10.20.30.44 10.20.30.45 10.20.30.46 10.20.30.47 10.20.30.48 10.20.30.49 10.20.30.50 Unfortunately this is non-obvious as GNU doesn't like to write man pages.


6

curl writes the output to stderr, so redirect that and also suppress the progress: curl -v --silent https://google.com/ 2>&1 | grep expire curl writes the information to stderr so you can do: curl <url> | someprgram without that information clobbering the input of someprogram


6

You don't really need the rename command for this, you can do it directly in the shell: c=0; for i in *; do let c++; mv "$i" "gg_$(printf "%03d" $c)${i#"${i%.*}"}"; done The printf "%03d" $c will print the $c variable, padding it with 3 leading 0s as needed. The let c++ increments the counter ($c). The ${i#"${i%.*}"} extracts the extension. More on that ...


5

Make a subdirectory tmp, move all all the files that you want to keep to that directory and do a rm -f * afterwards. That will not affect the tmp directory. After that just do: mv tmp/* . rmdir tmp (Assuming none of the files you moved starts with a dot). This is one of the few cases where it makes sense to use the mouse and a file browser like Nautilus ...


5

There are at least two programs named html2text (1) (2) which do this job.


5

You can use sed command with seq to print range of IP address. seq 2 23 | sed 's/^/10.0.0./' OR using echo and tr echo 10.0.0.{2..23} | tr ' ' '\n'


5

The simplest approach is to use the functionality already provided by bash. Specifically, the HISTIGNORE variable: HISTCONTROL A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespace, lines which begin with a space character are not ...


4

The usual remedy for things like this is stty sane The stty -echo should not have made this worse, as that just turns off echoing of input, and you already had that. The fact that you say returns just causes > to appear means that you've started somethng that is causing continuance over the next lines, e.g. echo ' will do that because it's waiting for ...


4

Instead of using ctrl + c use ctrl + z to put the action in the background. Or the better way of doing it would be to add an & at the end like so: serverbox:~ $ sudo shutdown -h +10 & The Ampersand: & The ampersand symbol tells the shell that it should execute the process in the background and return you to the prompt immediately. Normally ...


4

For gzip: $ gzip -l binutils-2.24.tar.gz compressed uncompressed ratio uncompressed_name 30809913 186997248 83.5% binutils-2.24.tar Now you see a compressed and an uncompressed size of the content. Or alternatively use that command: $ zcat binutils-2.24.tar.gz | wc --bytes 186997248 For bzip2, there is bzcat: $ ...


4

You can extract a value in your example with grep and assign it to the variable in the following way $ x=$(wget -0 - 'http://foo/bar.html' | grep -Po '<value.*strValue="\K[[:digit:]]*') $ echo $x 57 Explanation: $(): command substitution grep -P: grep with Perl regexp enable grep -o: grep shows only matched part of the line \K: do not show in the ...


4

Printing via CLI One method would be to use html2ps. $ html2ps http://example.com/file.html | lpr -or- $ html2ps http://example.com/file.html | lp -d someprinter Saving to PDF As an added bonus if you just want to keep it as a PDF file you can use ps2pdf like so: $ html2ps http://example.com/file.html | ps2pdf - somfile.pdf References Print a ...


4

elinks has -dump mode too elinks -dump https://www.google.com


4

If you define a function like loglast() { fc -ln -1 | sed 's/^[[:space:]]*//' >> "${1:-${logfile:-~/command.log}}" } then after every command you want to log, you can run loglast to log the previous command. The log file used is (in order): the optional first argument to loglast, or $logfile if no argument given, or $HOME/command.log as a last ...


4

Using ImageMagick: $ convert -crop 800x1000 image.png cropped_%d.png Will create a sequence of files named cropped_1.png, cropped_2.png, and so on. References Tile Cropping, sub-dividing one image into multiple images ImageMagick v6 Examples -- Cutting and Bordering


3

In zsh, easiest is to use run-help. Bring up your previous command (Up), and press Alt+H. That will bring up the documentation for curl. Once you exit man, you'll be back to where you were. Very handy when you need to see the manual in the middle of typing a command. Note that which documentation is displayed depends on where your cursor is on the command ...


3

In both bash and zsh (and (t)csh where that feature comes from), provided that history expansion is enabled: man !!:0 (admittedly, it's not really shorter than man curl).


3

You seem to be mistaken in that abc.py would not be a command. If you can execute it, then is, just one with a dot in the name. Execute in the sense that you can do ./abc.py, so the execute bits must be set. If you have to do python abc.py than you it is not a command (yet). In general, to make a normal python file abc.py executable you should make sure ...


3

I've edited @don_crissti's answer to allow pipe input: #!/usr/bin/env python import sys from gi.repository import Gtk, Gdk, GdkPixbuf def store(pixbuf): clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) clipboard.set_image(pixbuf) clipboard.store() def copy_image(f): image = Gtk.Image.new_from_file(f) if ...


3

Provided that there is an absence of ' single-quotes in the filenames, you might do this like: i=0; set -- for f in * do set -- "$@" "$f" gg "$((i+=1))" "${f#"${f%.*}"}" done printf "mv '%s' '%s%03d%s'\n" "$@" | sh That way if a filename contains a . then it and whatever follows it is retained, else that field is empty and printf prints nothing there. I ...


3

While it's true that some shell builtins may have a scant showing in a complete manual - especially for those bash-specific builtins that you're only likely to use on a GNU system (the GNU folks, as a rule, don't believe in man and prefer their own info pages) - the vast majority of POSIX utilities - shell builtins or otherwise - are very well represented in ...



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