Tag Info

Hot answers tagged


sudo touch /bin/rm && sudo chmod +x /bin/rm apt-get download coreutils sudo dpkg --unpack coreutils* And never again. Why didn't you used 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 ...


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). ...


just type: alias gb='cd /media/Dan/evolution' To make this setting permanent (so that it sticks after you restart or open another console) add this line to the file ~/.bashrc (assuming you use the bash as your default shell)


With GNU truncate: truncate -s 1M nullbytes would create a 1 mebibyte sparse files. That is a file that appears filled with zeros that doesn't take any space on disk. Without truncate, you can use dd instead: dd bs=1048576 seek=1 of=nullbytes count=0 (with some dd implementations, you can replace 1048576 with 1M) If you'd rather the disk space be ...


Alternative to aliasing gb() { cd /media/Dan/evolution; } This defines shell function gb, which takes no arguments, and performs cd /media/Dan/evolution. As with other suggeststions, this can be added to ~/.bashrc


What you want to do is use a pipe and greps -Z option: Using GNU grep and mv grep -LZ -- Attachments * | xargs -0 mv -t target_directory The -Z combined with xargs -0 handles any filenames with special characters. Using BSD grep and mv (like on MacOS X) grep -L --null -- Attachments * | while IFS= read -r -d "" file; do mv "./$file" ...


wget -qO- 'http://www.youtube.com/watch?v=Dd7dQh8u4Hc' | perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si' You can pipe it to GNU recode if there are things like &lt; in it: wget -qO- 'http://www.youtube.com/watch?v=Dd7dQh8u4Hc' | perl -l -0777 -ne 'print $1 if /<title.*?>\s*(.*?)\s*<\/title/si' | recode html.. ...


I would say because it's hardly ever necessary to create an empty file that you won't fill with content immediately on the command line or in shell scripting. There is absolutely no benefit in creating a file first and then using I/O redirection to write to the file if you can do so in one step. In those cases where you really want to create an empty file ...


nohup read the man page for nohup usage. nohup is the way it's been done long since before screen, tmux, etc were invented. Example: nohup my_long_running_proc & Runs "my_long_running_proc", and any console (stdout/stderr) messages go into a file called "nohup.out" in the directory from which the command was started.


dmidecode -s system-product-name I have tested on Vmware Workstation, VirtualBox, QEMU with KVM, standalone QEMU with Ubuntu as the guest OS. Others have added additional platforms that they're familiar with as well. Virtualization technolgies VMware Workstation root@router:~# dmidecode -s system-product-name VMware Virtual Platform VirtualBox ...


In normal mode, do 100dd. dd deletes the current line. Prefacing that command with 100 causes it to repeat 100 times.


UPDATE (2014-02-02) Thanks to our very own @Anthon's determination in following the lack of this feature up, we have a slightly more formal reason as to why this feature is lacking, which reiterates what I explained earlier: Re: [PATCH] ls: adding --zero/-z option, including tests From: Pádraig Brady Subject: Re: [PATCH] ls: adding --zero/-z ...


Probably going to get my knuckles rapped for this, here's a hacky combination of bash brace expansion and eval that seems to do the trick eval {stat,file}" fileName;"


dd if=/dev/zero of=/var/tmp/nullbytes count=1 bs=1M


Python imports a large number of files at startup: % python -c 'import sys; print len(sys.modules)' 39 Each of these requires an even greater number of attempts at opening a Python file, because there are many ways to define a module: % python -vv -c 'pass' # installing zipimport hook import zipimport # builtin # installed zipimport hook # trying ...


You can use brace expansions: convert -trim -density 400 this_is_a_very_long_filename_of_my_pdf_file.{pdf,png}


To me the "cd ../code" is a noop. I'm very interested into hearing why it isn't. Because files and directories are fundamentally filesystem inodes, not names -- this is perhaps an implementation detail specific to the filesystem type, but it is true for all the ext systems, so I'll stick to it here. When a new directory code is created, it is ...


You can also try hxselect (from HTML-XML-Utils) with wget as follows: wget -qO- 'http://www.youtube.com/watch?v=Dd7dQh8u4Hc' | hxselect -s '\n' -c 'title' 2>/dev/null You can install hxselect in Debian based distros using: sudo apt-get install html-xml-utils. STDERR redirection is to avoid the Input is not well-formed. (Maybe try normalize?) ...


With zsh, you can use anonymous functions: (){stat $1; file $1} filename With es lambdas: @{stat $1; file $1} filename You could also do: { stat -; file -;} < filename (doing the stat first as the file will update the access time). I'd do: f=filename; stat "$f"; file "$f" though, that's what variables are for.


There are 3 methods that I'm aware of: pwdx $ pwdx <PID> lsof $ lsof -p <PID> | grep cwd /proc $ readlink -e /proc/<PID>/cwd Examples Say we have this process. $ pgrep nautilus 12136 Then if we use pwdx: $ pwdx 12136 12136: /home/saml Or you can use lsof: $ lsof -p 12136 | grep cwd nautilus 12136 saml cwd DIR ...


You can use the !!:gs/search/replace/ notation to do what you want. This utilizes the global search & replace (:gs): before $ echo "harm warm swarm barm" harm warm swarm barm after $ !!:gs/arm/orn/ echo "horn worn sworn born" horn worn sworn born References The Definitive Guide to Bash Command Line History Caret search and replace in Bash shell ...


There are many ways to go about this. Method #1 - ps You can use the ps command to find the process ID for this process and then use the PID to kill the process. Example $ ps -eaf | grep [w]get saml 1713 1709 0 Dec10 pts/0 00:00:00 wget ... $ kill 1713 Method #2 - pgrep You can also find the process ID using pgrep. Example $ pgrep wget ...


With bash, you could use brace expansion mv blob/a_long_directory_name/{c/x.x,evenmore/y.y}


If you know that none if the file names contain new lines, tabs, spaces or glob combinations that may produce a match, this may be easier for a one off case: mv $(grep -L Attachments *) dest_dir


Yes, there is a big difference. && is short-circuiting, so the subsequent command would be executed only if the previous one returned with an exit code of 0. Quoting from the manual: expression1 && expression2 True if both expression1 and expression2 are true. On the other hand, a script containing expression1 expression2 would ...


sed Solution: sed -e 1b -e '$!d' file When reading from stdin if would look like this (for example ps -ef): ps -ef | sed -e 1b -e '$!d' UID PID PPID C STIME TTY TIME CMD root 1931 1837 0 20:05 pts/0 00:00:00 sed -e 1b -e $!d head & tail Solution: (head -n1 && tail -n1) <file When data is comming from a ...


Easy trick for alias in $(compgen -a); do type $alias; done


Using GNU grep for the colouring: color() { GREP_COLOR=$1 grep --color '.*'; } (tail -qf /var/log/syslog | color 31 & tail -qf /var/log/fail2ban.log | color 32 & tail -qf /var/log/nginx/error.log | color 33) Note that the first 2 are started in background. That means they won't be killed if you press Ctrl-C (shell explicitly ignore SIGINT for ...

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