When I use the following, I get a result as expected:
$ echo {8..10}
8 9 10
How can I use this brace expansion in an easy way, to get the following output?
$ echo {8..10}
08 09 10
I now that this may be obtained using seq (didn't try), but that is not what I am looking for.
Useful info may be that I am restricted to this bash version.
Usually in solaris/Linux servers , when you do an su - username (space before and after the hyphen) the user's .profile should get sourced. But in the below linux machine it is not.
I want to get vsftpd version into shell variable.
Hi guys,
could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?:
Code:
$ uname -a
Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64 GNU/Linux
$ bash --version
GNU bash, version 4.2.10(1)-release (x86_64-suse-linux-gnu)
$ awk --versi
I am some new to the programming world but starting to get hang of it.
My question is,what shell should I use bash or sh (Ubuntu uses dash for sh)
Is the one faster, users more memory etc?
Example scripts
Code:
#1
for I in {1..10}; do echo $I; done
#2
for I in 1 2 3 4 5 6 7 8 9 10; do echo $I; done
#3
for I in $(seq 1 10); do echo $I; done
#4
for ((I=1; I <= 10 ; I++)
Ok so I got a little bored and desided to make a fun little bash script that you can use to scare Linux neewbies :)
Here is the code:
Quote:
#!/bin/bash
clear
echo "Formating disk(s): " /dev/sd*
sleep 2
echo "Initialising..."
sleep 2
echo "Are you sure you want to format these disks?"
# Declare variable choice and assign value
I am a bash beginner and observed the below behavior of echo
#!/bin/bash
x=" hello"
echo $x
echo "$x"
Now when I run the above code I get
ronnie@ronnie:~$ bash test.sh
hello
hello
ronnie@ronnie:~$
So, can someone explain to me why whitespace in first case is not present in output and also points me to the documentation where this behavior is defined.
For Bash versions prior to "GNU bash, Version 4.2" are there any equivalent alternatives for the -v option of the test command? For example:
shopt -os nounset
test -v foobar && echo foo || echo bar
# Output: bar
foobar=
test -v foobar && echo foo || echo bar
# Output: foo
I want to used sed or some other linux command to convert special characters in XML files.
Here is an example:
-bash-3.2$ echo "P&G"
P&G
Now I want to change the "&" to "&" so I run:
-bash-3.2$ echo "P&G" | sed -e "s/&/&/ig"
P&G
I got the result I want, but if someone runs the conversion program again,