Dear Sir,
May I know how do I go about adding the following feature into the script below:
When user enter values other than 1,2,3,4,
a) Message “Wrong entry !!!
In python this would be easy:
Code:
if test_var in ["a","b","c"]: print "Yes"
...but is there a way to do the same in bash?
Hi Guys,
I am relatively new to scripting at the moment and am struggling to get the following function to work. For some reason it does not recognise the arithmatic symbol when i select option1. Any help would be greatly appreciated.
Code:
menu ()
{
echo "=============="
echo "Calculator"
echo "=============="
echo "1. Divide"
echo "2.
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,
Hi,
I have a .sh file, to email a report of our backups from a linux machine.
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.
Rather than reinvent the wheel, if anyone knows a shell program which does this well ,please recommend
my bash / sed program is failing at the 'mv' to the new filename
it splits the original filename into multiple tokens
my loop is as follows:
Code:
echo "extension:"
read ext
ls --quoting-style=shell *.$ext | while read x ; do
n=`echo $x|sed -e "s/$ext//"` # reserve
Doomicide wrote:Here's a little bashscript, I wrote out of boredom, inspired by sunjacks' zsh script.http://ompldr.org/vYjVqOQ#!/bin/bash
XFILE="$HOME/.Xdefaults"
COLS="$(cat $XFILE| grep -Ei urxvt[.*]color[01-9] | sort -n -tr -k2 | cut -d: -f2 | tr -d [:blank:])"
for i in {0..7}; do echo -en "\e[0;3${i}m ▉▉ $(echo "$COLS" | sed -n $(($i+1))'p&#
Hi
As bash does not support multidimensional arrays (?), I need some help with a problem.