Search Results

Search: Posts Made By: gangsta
7,449
Posted By CarloM
Try htmlcode=$(mktemp -t htmlcode.XXXXXXXXXX) ...
Try
htmlcode=$(mktemp -t htmlcode.XXXXXXXXXX)
...
echo "$text" >> $htmlcode
6,781
Posted By m.d.ludwig
Here is my results: ludwig$ bash x ...
Here is my results:

ludwig$ bash x
<CTRL-C> to quit
<CTRL-C> to quit
<CTRL-C> to quit
<CTRL-C> to quit
<CTRL-C> to quit
.
.
.
<CTRL-C> to quit
<CTRL-C> to quit
<CTRL-C> to quit...
6,781
Posted By m.d.ludwig
#! /bin/bash trap_ctrlC() { echo...
#! /bin/bash

trap_ctrlC() {
echo '<CTRL-C> has been trapped'
read -p 'Enter to exit: ' line
exit 1
}

trap trap_ctrlC INT

while true; do
echo '<CTRL-C> to quit'
done
2,326
Posted By Chubler_XL
Replace all the break;; with ;;
Replace all the break;; with ;;
2,807
Posted By cfajohnson
#!/bin/bash is_int() { case $1 in ...
#!/bin/bash
is_int()
{
case $1 in
*[!0-9]*|"") return 1 ;;
esac
}

while :
do
read -ep "How many cars to enter: " tot
is_int "$tot" && [ "$tot" -gt 0 ] && break
printf...
2,807
Posted By Chubler_XL
It will contain things like:Input: two line 5:...
It will contain things like:Input: two
line 5: [: two: integer expression expected
Input:
line 5: [: -ge: unary operator expected

@gangsta: you want this then:
read -p "How many cars to...
2,807
Posted By Chubler_XL
How about this example in bash : while true...
How about this example in bash :

while true
do
read -p "How many cars to enter: " tot
[ $tot -ge 0 ] 2>/dev/null && break
echo "Invalid number. re-enter"
done
num=0
while [ $num...
2,309
Posted By Chubler_XL
Assumption: Your trying to validate user input...
Assumption: Your trying to validate user input against a list of valid responses (in cars_names.txt).

read -p "Car: " cars1
until grep -wiq "$cars1" cars_names.txt && [ -n "$cars1" ]
do
...
2,309
Posted By cfajohnson
You are using a numeric comparison (-eq) for...
You are using a numeric comparison (-eq) for strings. Use string comparison:

until [ "$cars1" = cars_names.txt ]
do
read -ep "Invalid cars. Try again: " cars1
done
1,179
Posted By balajesuri
read -p "Enter a car model: " car1 grep -w...
read -p "Enter a car model: " car1
grep -w $car1 carMakes.txt
test $? -ne 0 && echo "Car not found, try again please"
2,326
Posted By felipe.vinturin
You don't really need to use "if" statements, you...
You don't really need to use "if" statements, you can use "case":

while true
do
clear
echo "Menu Options: "
echo " 1. Create Script"
echo " 2. Show Script"
echo " 3. Delete...
21,111
Posted By Corona688
Usually, you don't. You could do something...
Usually, you don't.

You could do something like [ -f file ] || echo "doesn't exist" && exit 1 but what if the echo fails for some reason? Then you won't exit.

You could combine statements like...
35,926
Posted By vbe
From man pages: To be able in ONE...
From man pages:


To be able in ONE command, mkdir that is you will have no other choice but to give the 2 directories in argument and using -p option:

mkdir -p test/test1 test/test2

which...
35,926
Posted By DGPickett
mkdir -p test/test1/test2
mkdir -p test/test1/test2
Showing results 1 to 14 of 14

 
All times are GMT -4. The time now is 11:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy