bash


linux - Using the passwd command from within a shell script

from "man 1 passwd": --stdin This option is used to indicate that passwd should read the new password from standard input, which can be a pipe. So in your case adduser "$1" echo "... Read More


linux - How to get the name of the current git branch into a variable in a shell script?

The * is expanded, what you can do is use sed instead of grep and get the name of the branch immediately: branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') And a version using git symbolic-ref, as... Read More


linux - Command output redirect to file and terminal

Yes, if you redirect the output, it won't appear on the console. Use tee. ls 2>&1 | tee /tmp/ls.txt... Read More


shell - How can I repeat a character in Bash?

You can use: printf '=%.0s' {1..100} How this works: Bash expands {1..100} so the command becomes: printf '=%.0s' 1 2 3 4 ... 100 I've set printf's format to =%.0s which means that it will always p... Read More


bash - Repeatedly run a shell command until it fails?

while takes a command to execute, so you can use the simpler while ./runtest; do :; done This will stop the loop when ./runtest returns a nonzero exit code (which is usually indicative of failure).... Read More


linux - How do I get cURL to not show the progress bar?

curl -s http://google.com > temp.html works for curl version 7.19.5 on Ubuntu 9.10 (no progress bar). But if for some reason that does not work on your platform, you could always redirect stderr to... Read More


ubuntu - .bashrc at ssh login

.bashrc is not sourced when you log in using SSH. You need to source it in your .bash_profile like this: if [ -f ~/.bashrc ]; then . ~/.bashrc fi... Read More


linux - how do I check in bash whether a file was created more than x time ago?

Only for modification time if test `find "text.txt" -mmin +120` then echo old enough fi You can use -cmin for change or -amin for access time. As others pointed I don’t think you can track creati... Read More


Is it possible to detect 32 bit vs 64 bit in a bash script?

MACHINE_TYPE=`uname -m` if [ ${MACHINE_TYPE} == 'x86_64' ]; then # 64-bit stuff here else # 32-bit stuff here fi... Read More


bash - setting tabwidth to 4 in git show / git diff

I believe git config --global core.pager 'less -x1,5' References: Original: (No longer valid) git-scm chp7-1 Newer: git-config#git-config-corepager Customizing Git... Read More