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++)
I need to check whether first character of variable is single quote.
I tried the below constructions but they are all not working (always return true)
Code:
if (test `echo "$REGEXP" |cut -c1` != "'"); then echo "TRUE"; fi
if (test `echo "$REGEXP" |cut -c1` != '\''); then echo "TRUE"; fi
if (test `echo "$REGEXP" |cut -c1` != `printf &
hello,
I'm trying to display Unix variable using printf command.
Code:
Code:
awk '{ if ( $0 ~ /string/ ) {
printf( "%s\n%s\n",$0,"dsd"); #this one works
printf( "%s\n%s\n",$0,$HOME); #this does not work
} else {
print $0;
}
}' param1_1.txt
I could use here echo command but I'm not sure how to use it properly.
I mean "properly" because the in
Hi guys...was trying to use while loop and a sentry to prompt user input again if an invalid option was entered...but somehow I got a "while" unmatched error...The code is as below:
Code:
#!/system/bin/sh
finsh=0
while [ $finish -ne 0 ]
do
echo "Please select an option: "
echo "1. One" echo "2. Two"
echo "3. Three"
echo "4.
Hi ,
I have script as follows ,
#!/usr/bin/ksh -x
if [ `uname` = "Linux" ]
then
alias echo="echo -e"
fi
MAX_ENTRIES=1024
nb_of_entries=`echo "$list_of_entries" | wc -w`
# Set number of tables
eval nb_of_tables=\`expr `expr $nb_of_entries / $MAX_ENTRIES` + 1 \`
# Output the number of tables
echo $nb_of_tables
Here "list of entries" is list of PID's and
Heh, working on a bash script to chop up a file based on its filesize.
How can the white space character be escaped in printf for the purpose of this script that currently runs in a Cygwin client?
Hi,
I am in a situation to print the message on a column, where the each line starting position should be same.
For example code:
Code:
HOSTNAME1="1.2.3.4.5.6.7"
TARGET_DIR="/tmp"
echo "HOSTNAME1:" "$HOSTNAME1" | awk -v var="Everyone" '{len=55-length;printf("%s%*s\n",$0,len,var)}'
echo "TARGET_DIR:" "$
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,