I need to get a list of human readable du output.
However, du does not have a "sort by size" option, and piping to sort doesn't work with the human readable flag.
For example, running:
du | sort -n -r
Outputs a sorted disk usage by size…
What is the best way to determine if a variable in bash is empty ("")?
I have heard that it is recommended that I do if [ "x$variable" = "x" ]
Is that the correct way? (there must be something more straightforward)
I just wondered what exactly the difference between
[[ $STRING != foo ]]
[ $STRING != foo ]
is, apart from that the latter is POSIX-compliant, found in sh and the former is an extension found in bash.
Is there a way to run a command (e.g. ps aux|grep someprocess) for n times?
run -n 10 'ps aux|grep someprocess'
I want to use it interactively.
Update: The reason I am asking this is, that I do work on a lot of machines and I don't…
I have an array which gets filled with different error messages as my script runs.
I need a way to check if it is empty of not at the end of the script and take a specific action if it is.
I have already tried treating it like a normal VAR and using…
I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash).
alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for this?
I wasn't root and cancelled the command…
sleep is a very popular command and we can start sleep from 1 second:
# wait one second please
but what the alternative if I need to wait only 0.1 second or between 0.1 to 1 second ?
remark: on linux or OS X sleep 0.XXX works fine , but…
Try executing the following under a bash shell echo "Reboot your instance!"
On my installation:
root@domU-12-31-39-04-11-83:/usr/local/bin# bash --version
GNU bash, version 4.1.5(1)-release (i686-pc-linux-gnu)
Copyright (C) 2009 Free Software…
I want to run a bash subshell, (1) run a few commands, (2) and then remain in that subshell to do as I please. I can do each of these individually:
Run command using -c flag:
$> bash -c "ls; pwd; "
however, it immediately…
I'm connecting to a Linux machine through SSH, and I'm trying to run a heavy bash script that makes filesystem operations. It's expected to keep running for hours, but I cannot leave the SSH session open because of internet connections issues I…