On Thu, 2020-07-23 at 10:49 -0400, Jerry Geis wrote:
> Sorry - I see it now "remove the cat".
>
> Thanks "All" for the suggestions. I wasnt aware of the method to
> avoid the
> cut command.
>
Here's a few "historical" observations on this thread.
1) Your original script looks like you were
Sorry - I see it now "remove the cat".
Thanks "All" for the suggestions. I wasnt aware of the method to avoid the
cut command.
Jerry
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos
On 23/07/2020 16:37, Jerry Geis wrote:
Thanks, when I change it do the following I get a syntax error
#!/bin/bash
#
while read LINE
do
echo $LINE
done < cat list.txt
You don't use "cat" here; it's not needed at all. You write:
done < list.txt
This tells the shell to redirect the
On 23/07/2020 15:37, Jerry Geis wrote:
Thanks, when I change it do the following I get a syntax error
#!/bin/bash
#
while read LINE
do
echo $LINE
done < cat list.txt
done < list.txt
./test_bash.sh
./test_bash.sh: line 6: syntax error near unexpected token `list.txt'
On Thu, Jul 23, 2020 at 4:25 PM Anand Buddhdev wrote:
> On 23/07/2020 15:46, Jerry Geis wrote:
>
> Hi Jerry,
>
> See below, inline, for some comments.
>
>
> > while read -r LINE
> > do
> > NODENAME=` echo $LINE | cut -f 1 -d ','`
>
> NODENAME=$(cut -d, -f1 <<< $LINE)
>
> Notes: use $( instead
On 23/07/2020 15:46, Jerry Geis wrote:
Hi Jerry,
You can do even better:
index=0
total=0
names=()
ip=()
IFS=,
while read -r NODENAME IP
do
names[$index]="$NODENAME"
ip[$((index++))]="$IP"
((total++))
done < list.txt
In this example, you set the input field separator (IFS) to the
Thanks, when I change it do the following I get a syntax error
#!/bin/bash
#
while read LINE
do
echo $LINE
done < cat list.txt
./test_bash.sh
./test_bash.sh: line 6: syntax error near unexpected token `list.txt'
./test_bash.sh: line 6: ` done < cat list.txt'
Hi,
Some remarks:
- just try « expr ${VAR} + 1 » (with blanc between car)
- use simple redirection (« < ») with a simple reference to file (« done <
list.txt »)
- use « ${VAR} » to manage variables
- you can use numeric notation to increment VAR (p.e. « total=$(( ${total} + 1
)) »)
An other
On 23/07/2020 15:46, Jerry Geis wrote:
Hi Jerry,
See below, inline, for some comments.
I have a simple script:
#!/bin/bash
#
index=0
total=0
names=()
ip=()
while read -r LINE
do
NODENAME=` echo $LINE | cut -f 1 -d ','`
NODENAME=$(cut -d, -f1 <<< $LINE)
Notes: use $( instead of backticks.
I have a simple script:
#!/bin/bash
#
index=0
total=0
names=()
ip=()
while read -r LINE
do
NODENAME=` echo $LINE | cut -f 1 -d ','`
IP=` echo $LINE | cut -f 2 -d ','`
names[index]="$NODENAME"
ip[index]="$IP"
index=`expr index+1`
total=`expr total+1`
done <<< $(cat list.txt)
simple file:
10 matches
Mail list logo