Tag Info

Hot answers tagged

4

You can use the DEBUG trap to do this. In this trap, $BASH_COMMAND contains the command last executed. trap 'echo "you tried to call the command [$BASH_COMMAND]"' DEBUG Note that, if you are executing commands as part of your prompt or $PROMPT_COMMAND, the trap will run on these as well. You can add checks to see if $BASH_COMMAND is the same as ...


3

You're on Ubuntu, so I'll assume you're using bash. When you define a variable, you do it like this: you@ubuntu:~$ a="hello" No spaces. No dollar sign. It won't work otherwise. You use the dollar sign whenever you want to use that variable you defined: you@ubuntu:~$ echo $a hello Your third command should output the literal letter 'a': you@ubuntu:~$ ...


2

The role of an X11 window manager is quite complex. First, learn more about X core protocol and X architecture. Then read EWMH if you need to understand the conventional roles of WMs (also known and respected by X11 toolkits like GTK, Qt, etc...). Even single-application but multiple-windows (e.g. popups) programs practically need some WM Then you could ...


2

I suspect that you're looking for set -o notify, available in ksh, bash, zsh, and even POSIX sh, which causes job completion notifications to be printed immediately, even if you're at typing a prompt or if some other job is in the foreground. (If that's not what you're looking for, please clarify your question, maybe with an example of how it would look ...


1

Here's a quick script I wrote further to my comment, that in the SIMPLE case of aliases will work. For anything with arguments/etc., though, it will fail miserably. cmd="$1" type=aliased while [ "$type" = "aliased" ]; do output="$(type "$cmd")" type="$(cut -d ' ' -f 3 <<< "$output")" cmd="$(cut -d '`' -f 2 <<< "$output" | tr -d ...


1

You could use shuf: shuf -zn8 -e *.jpg | xargs -0 cp -vt target/ shuf shuffles the list of *.jpg files in the current directory. -z is to zero-terminate each line, so that files with special characters are treated correctly. -n8 exits shuf after 8 files. xargs -0 reads the input delimited by a null character (from shuf -z) and runs cp. -v is to print ...


1

You could retrieve files in this way: files=(/tmp/*.jpg) n=${#files[@]} file_to_retrieve="${files[RANDOM % n]}" cp $file_to_retrieve <destination> make a loop 8 times. Hope it helps


1

The following bash one-liner will do approximately what you describe, putting each directory into its own tarball. for d in dir/*/; do { tar -cj "$d" > "${d%/}.tar.bz2" ; } & done ; while [ "$(jobs)" ] ; do fg &>/dev/null ; done ; echo done


1

PATH Variables needed to be added. cd ~ vi .profile Append: :/home/user/.local/lib/aws/bin/ Behind: PATH=":$HOME/bin # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH:/home/user/.local/lib/aws/bin/" fi aws --version


1

Here comes a memo to resize an NTFS partition using commandline with ntfsresize (from the ntfs-3g / ntfsprogs package) and fdisk, that should work for Windows XP-to-8 versions. Note that GParted does all the following for MBR/DOS as well as for EFI/GPT drives if ntfs-3g / ntfsprogs is installed. My references are at the end. OK in this scenario I have a ...



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