Tag Info

Hot answers tagged

19

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.


12

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.


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


2

Use parted instead, possibly coupled with your filesystem's resizing command. parted is the engine underneath the GParted GUI. You can use it in either interactive command mode or directly from the command line. Before parted 3.0, the following command does what you are probably expecting, having learned about GParted: $ sudo parted /dev/sdb resize 1 1 ...


2

To squash multiple hyphens (one hyphen followed by one or more hyphens) into a single one for all files in the current directory use: rename 's/--+/-/g' -- * The -- is important if files start with a hyphen, otherwise they would be interpreted as command line arguments. The * expands to the list of files in the current directory.


2

find(1): -newerXY reference Compares the timestamp of the current file with reference. The reference argument is normally the name of a file (and one of its timestamps is used for the comparison) but it may also be a string describing an absolute time. X and Y are placeholders for other letters, ...


2

| sort | uniq -c As stated in the comments. Piping the output into sort, organises the output into alphabetical/numerical order. This is a requirement because uniq only matches on repeated lines, ie a b a If you use uniq on this text file, it will return the following. This is because the a is separated by the b - they are not repeating lines. a b a ...


1

I don't think it'd be common to interpret tool -f BAR | --foo BAR as «pipe the output of tool -f BAR into the command --foo BAR». So I'd use simply tool -f BAR | --foo BAR There's other possibilities in the wild using additional markup, specially if the invocation is more complex, to make it more obvious. Unlike with optional arguments and [] though, none ...


1

A better way to get local users might be to see if the user has a valid login shell: getent passwd | grep -f /etc/shells Here's something that should work: getent passwd | grep -f /etc/shells | tr ',' ':' | \ awk -F: '{print $1, $5}' | while read USER NAME do echo $NAME:$(chage -l $USER| awk -F': ' '/Password expires/{print $2}') ...


1

Don't use sudo in init scripts. They're run as root to start with. If you were to use sudo in /etc/rc.local (which as per #1 there is no point in doing), you need to provide a $PATH or the path to the executable because there is no $PATH set when this is run at boot by init. So, e.g., if you wanted to run ls, first find out where it is: whereis ls ...



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