Search Results

Search: Posts Made By: ksmarine1980
5,156
Posted By cjcox
Doesn't really make much sense to say which is...
Doesn't really make much sense to say which is closer, however you could at least say that the default gateway of 10.0.0.1 is out through eth1 on the 10.0.0.0/24 network.

Your host knows where...
5,156
Posted By hergp
What the example says is this: If you want...
What the example says is this:

If you want to send to a system in the 10.0.0.0 network, you don't have to use a gateway (router). Just send the packet out of the eth1 interface and the destination...
9,845
Posted By RudiC
That is because you printf "SP" without a comma....
That is because you printf "SP" without a comma. In fact, it's the ${morse["I"]} following the space in input.

---------- Post updated at 19:31 ---------- Previous update was at 18:56 ----------
...
9,845
Posted By junior-helper
-;.-;-;--SP-;.;.;..;--;.;.SPSP.;.;.;...;.;.;..SPSP...
-;.-;-;--SP-;.;.;..;--;.;.SPSP.;.;.;...;.;.;..SPSP.;-;.;.-;-;--;-;--;.;-.;.-;.-;-;.SP.;.;-;.-;-;--;-;.;-.;-;-.;--;-;.;--;.;.SP--;-;-SP.;.;...SP-.;.;.;..SP-;.;-;.-;-;--;.;..EOT
9,845
Posted By sea
Thats a fun excercise :D Here is my test to...
Thats a fun excercise :D

Here is my test to reverse the input as well:
I mean, it has to be able to translate it both ways, doesnt it? ;)
+ ~ $ morse "Hello UNIX DOT com"...
9,845
Posted By junior-helper
Just add a newline character to the printf...
Just add a newline character to the printf command
printf "%s\n" SPDon't forget to do the same for the other printf command between else and fi.
The third printf does not need to be modified.
...
9,845
Posted By junior-helper
Potential improvement: N=${input:$i:1} ...
Potential improvement:
N=${input:$i:1}

if [ "$N" = " " ]; then
printf "%s" SP
else
printf "%s" "${morse[$N]}"
fi
done

printf "%s\n" EOT
9,845
Posted By jim mcnamara
Declare the array BEFORE you execute the loop.
Declare the array BEFORE you execute the loop.
9,845
Posted By Don Cragun
And, don't use the same name for a scalar...
And, don't use the same name for a scalar variable and an array variable.
9,845
Posted By ongoto
Is this the idea? I put the loop at the end so...
Is this the idea?
I put the loop at the end so bash will see the array
as it reads top down. I think that's right...
I'm not sure I got the associative array part right though? echo...
5,689
Posted By Chubler_XL
[ and ] must have a spaces before and after them
[ and ] must have a spaces before and after them
5,689
Posted By junior-helper
Try this code (note it needs to be "hardened",...
Try this code (note it needs to be "hardened", e.g. checking if $1 and $2 were supplied, is $1 less than $2, etc.):
#!/bin/bash

ARGSTART=$1
ARGSTOP=$2

COUNT=0

while IFS= read -r line; do
...
10,783
Posted By migurus
Don uses string substitution feature of bash, you...
Don uses string substitution feature of bash, you can man bash and read all the details

To demonstrate:



$ a="123 abc # qwe"
$ echo ${a#*#}
qwe

$ a="123 abc + qwe"
$ echo...
10,783
Posted By Don Cragun
Don't tell us it "prompts me for more info"; show...
Don't tell us it "prompts me for more info"; show us the exact message that bash prints as a prompt.

When I save the following:
#!/bin/bash
found=0
n=1
while read -r line
do # Look for...
10,783
Posted By RavinderSingh13
Hello ksmarine1980, Following may help you...
Hello ksmarine1980,

Following may help you in same if we need to print line number along with line's content.


i- awk '{print NR OFS $0}' Input_file
ii- cat -n Input_file
iii- while read...
10,783
Posted By RavinderSingh13
Hello ksmarine1980, Not sure if I am...
Hello ksmarine1980,

Not sure if I am correct, but I have given a while loop solution also in my previous post. Could you please let me know if that helps or you need anything else here.

...
10,783
Posted By MadeInGermany
In command arguments have variables in quotes! ...
In command arguments have variables in quotes!
echo "$line"
echo "$i $line"
Other suggestions:
printf "%05d %s\n" $i "$line"
read -r ...
10,783
Posted By Don Cragun
For the purposes of this exercise, how do you...
For the purposes of this exercise, how do you define "comment"?

A basic outline of what you want is something like:
#!/bin/bash
n=1
while read -r line
do if [ comment_present ]
...
10,039
Posted By Corona688
That last statement looks over-complicated to me...
That last statement looks over-complicated to me I think:

if ( $2 == "string" ) then
...
else if ( $2 == "other" ) then
...
else
echo "operator is invalid or missing"
endif

But...
10,039
Posted By Corona688
I told you both ways. CSH is not UNIX, it's a...
I told you both ways. CSH is not UNIX, it's a nonstandard language which was popular in the early 80's(it supported "fancy" things like line editing!) but has only clung to a weird, tenuous life...
10,039
Posted By Don Cragun
I generally refuse to use csh and its derivatives...
I generally refuse to use csh and its derivatives for reasons already mentioned in this thread... But, I think you want to change:
else if ( $2 =~ "times" ) then
@ c = $1 * $3
...
1,458
Posted By Chubler_XL
Be sure to test it with the same number...
Be sure to test it with the same number duplicated several times.

{
for (i=1; i<=NF; i++) {
if($i=="0" || $i+0 != 0) {
array[$i+0]++
if ($i+0 > max)...
1,458
Posted By Chubler_XL
Populating A[] and calculate count and average: ...
Populating A[] and calculate count and average:

{
$1=$1
for (i=1; i<=NF; i++) {
if($i=="0" || $i+0 != 0) {
A[++count]=$i+0
tot+=$i+0
if ($i+0 > max) max=$i+0...
1,458
Posted By Chubler_XL
Try this: { ...
Try this:

{
gsub(/[^[:space:]]*[^[:digit:][:space:]][^[:space:]]*/,x,$0)
$1=$1
for (i=1; i<=NF; i++) {
if ($i > max) max=$i
if($i < min || !min) min=$i
}
}
END{
...
1,458
Posted By jim mcnamara
This will clean out all non-digits (you need the...
This will clean out all non-digits (you need the . character for decimal numbers)

tr -d '[:alpha:]' < infile > newfile

If you want better answers please post examples of sample input and...
Showing results 1 to 25 of 31

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