ingopingo
  • Member for 7 years, 5 months
  • Last seen more than a month ago
How can I check mail from the command line?
9 votes

mutt is the right choice, try mutt -f "imaps://USER:PASS@imap.gmail.com/INBOX" Press ? to show keyboard commands.

View answer
Show sum of file sizes in directory listing
8 votes

with perl: perl -le 'map { $sum += -s } @ARGV; print $sum' -- *.pdf Size of all non-hidden PDF files in current directory.

View answer
Applying the chmod and chown commands dynamically to the output of find command
3 votes

tee clone the pipe and xargs feeds every command with arguments: find -name 'myawesomeapp.jar' -print0 | tee >(xargs -0 chown root:webapps) | xargs -0 chmod 640

View answer
Parallelise rsync using GNU Parallel
2 votes

For multi destination syncs, I am using parallel rsync -avi /path/to/source ::: host1: host2: host3: Hint: All ssh connections are established with public keys in ~/.ssh/authorized_keys

View answer
Does Grub2 have a way of uniquely labelling the menu entries that can be used to set the default for booting?
2 votes

Set the exact name from the menuentry as GRUB_DEFAULT, for example Ubuntu, with Linux 4.4.0-62-generic (upstart), see: perl -lne "print \$1 if /menuentry '(.*?)'/" /boot/grub/grub.cfg

View answer
iptables problem new ip andresse
2 votes

Use ipset for black- or whitelists, so the iptables rule is always the same: ipset create whitewall hash:net ipset add whitewall 123.156.4.6 ipset add whitewall 23.56.78.8 ipset add whitewall 21.4.5....

View answer
Script for modifying cronjob
Accepted answer
2 votes

Julies simple solution, stopping and restarting the service as script (Debian Linux): #!/bin/sh service cron stop ... dowhatyouwant ... service cron start Or delete the crontab temporary: crontab -...

View answer
Splitting gzip-file into smaller gz-files without recompressing
2 votes

Split and join of the big file works, but it is impossible to decompress pieces of the compressed file, because essential informations are distributed through the whole dataset. Another way; split the ...

View answer
Copy disc layout and partitions to another drive
2 votes

The MBR Partion is sector 0 of the disk, clone it with dd: sudo dd if=/dev/sda of=/dev/sdb bs=512 count=1 Beware: the data of the target disk may be destroyed. To activate the new partitions, you ...

View answer
Find files containing text, but report different part of it as result
1 votes

What is the "Title" of a file, the path or name? Use the --files-with-matches option or -l to list matched filenames. If you search only fixed strings instead of regular expressions, speed up the ...

View answer
Mac: easiest way to move multiple duplicate file names to same directory
Accepted answer
1 votes

Use the interactive options -i to keep duplicate files. If you redirect /dev/null into mv, all overwrite questions are answered with no: cd /folder1 mv -i * /folder2 < /dev/null After this ...

View answer
VNC over Raspberry Pi router using port forwarding
1 votes

Your script works and creates this iptables entries: # iptables -L FORWARD -nv Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source ...

View answer
Wget Won't Recursively Download
1 votes

Try this one: wget -nv --mirror --span-hosts --convert-links --adjust-extension --page-requisites --no-parent https://some.site.com/foo/bar/threadNumber This commands get the whole thread with all ...

View answer
unzip nested .zip files by name shell script
Accepted answer
1 votes

Create a script file like fetchtarget.sh and start it with the URL as first argument. #!/bin/sh dir=$(mktemp -d) cd $dir || exit wget $1 # deep unzip loop while true; do find -iname '*.zip' >...

View answer
Renaming directories based on a pattern
1 votes

find and rename is a powerful team. With the -0 option, all possible filenames are cleanly handled: find -maxdepth 1 -type d -print0 | xargs -0 rename s/.*Directory-/Directory-/

View answer
Debian/Kali – Problem with writing to /etc/resolv.conf
1 votes

If your /etc/resolv.conf is autogenerated by NetworkManager, it will be overwritten at many network events like DHCP-Requests. This is done by the resolvconf package. See man resolvconf (head and tail ...

View answer
Use sed to add character in n'th position of matching string
1 votes

CSV parsing and processing may be real complex. Here is a perl oneliner which put the N in front of column one and three, independently of the content: Step 1, strip the double quotes: @F = map { /"(...

View answer
How to run cronjob every 4 hours minus 1 second
1 votes

Seconds and negative time are not possible in crontab. Simply wait 59 seconds in the 59th minute of the previous hour. Example crontab: # # minute 0-59 # hour 0-23 # dom 1-31 # mon 1-12 (...

View answer
Find all older versions based on version in filename
Accepted answer
1 votes

You need a compley regex to isolate the moving version string. Delimited the basename with a unused character and sort it unique. For example, build a index file with = as delimter: perl -le 'map { ...

View answer
Save many small files to LTO Tape
1 votes

The size of a tar archive is not the calculated size. Only a preflight run delivers the right size, but it doubles the workload. A example: ~# du -csb /usr | tail -1 | cut -f1 => 1585916720 ~# ...

View answer
Concurrency problems with GNU parallel
Accepted answer
1 votes

Why the extra batchfile, if you use parallel? parallel -j3 --delay 1 ./sub_script ::: 20141001 20141002 20141003 20141004 20141005

View answer
How can I Print output lines of this script uniqely and for every line print how many times is it repeated
0 votes

A simple perl script ... #!/usr/bin/perl my %hash; open FH, 'who |' or die; while ( <FH> ) { $hash{$1}++ if /^(\S+).*(10\.\d+\.\d+\.\d+)/; } close FH; while ( ($k,$v) = each %hash ) { ...

View answer
How to change file name like file_name.mt2 to file_name.mt0002?
0 votes

Larry Walls simple but powerful rename command is the right choice: rename 's/(\d+)$/sprintf("%04d",$1)/e' file*

View answer
How to identify which disk failed on RAID 10?
0 votes

If it is a software raid, take a look at the status # cat /proc/mdstat Personalities : [raid10] [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] md0 : active raid10 sdb2[1] sdd2[3] sdc2[2]...

View answer
Iterating through folders in numerical order
0 votes

Create a tiny perlscript to sort the arguments passed by the shell: #!/usr/bin/perl -l -s $re ||= qr/(\d+)/; sub bynum { ($aa) = $a =~ $re; ($bb) = $b =~ $re; return $aa <=> $bb; } ...

View answer
Mounting nix VM Guest Filesystem from Host with Dokan and WIn SSHFS
0 votes

Shared folder? sshfs is a fuse/dokan filesystem to access remote files via the ssh protocol, no matter of real or virtual. If you have the guest filesystem mounted as shared folder, you have already ...

View answer
How to merge two csv files with common but differently ordered headers?
0 votes

Save the code as file mergecols, make it executable and start it with mergecols -C1=0,2,3,4 -C2=0,2,1,3 file1 file2 #!/usr/bin/perl -s # mergecols # -C1=0,2,3,4 columns from file 1 # -C2=0,2,1,3 ...

View answer
Change executable path of app Ubuntu 16.04
0 votes

Create a robomongo script with the needed commands. The first line is used by the loader to find the right executable for the script. Later, the $* is replaced with the parameters. Make it executable ...

View answer
auditd script through crontab - bad date
0 votes

cron runs with a restricted enviroment, you must extend it. Set the PATH variable to the same value as your current enviroment. crontab example: PATH=/home/xxxxx/bin:/usr/local/bin:/usr/bin:/bin ...

View answer
Combining enscript, find, iconv and ps2pdf
0 votes

Create a java2ps script to easying the parameter handling #!/bin/bash export ENSCRIPT=" --portrait --columns=1 --font=Courier8 --highlight=java --color --line-numbers --output=- " iconv -f utf-8 -t ...

View answer