B
tried to figure out how on earth I am supposed to use cat or a for loop in a search
8 count=0
9
10
11 while read name
12
13 do
14 count=$((count + 1))
15 echo $navn
16
17 done < navn-1.txt
18
19 echo " "
20 echo "found $count names"
21 echo " "
___________
6 # v.1.0
7
8 teller=0 #count
9 IFS=$'\n'
10
11 for navn in $(cat navn-1.txt)
12
13 do
14 teller=$((teller + 1))
15 echo $navn
16
17 done
18
19 echo " "
20 echo "Det var $teller navn tilsammen"
21 echo " "
=======================
I am supposed to use one of those to change another assignment I did where I search a text file for two inputs, then print the lines matching both inputs
but I can't find a way to use it, because whatever argument i put behind cat, the bash shell expects to be a filename (or so it seems)
one question though:
17 done < navn-1.txt
I know this one redirects the contents of navn into the loop
but HOW does it do it? done finishes the loop, so how can the loop use the contents when it is directed into the done command? any ideas?
I know that, that's why it makes no sense
when I do that, the loop above WILL use the input of the file, how can it be inputed into the end of the loop?
============INPUT:
Bjørn Bjørnsen, Mosjøen, Informasjonsvitenskap
Bjørn Pedersen, Mo i Rana, Informatikk
Øyvind Østensen, Mo i Rana, Informatikk
Anders Bjærtnes, Mosjøen, Informatikk
Anne Båtvik, Mo i Rana, Informasjonsvitenskap
Ågot Ærtnes, Sandnessjøen, Informasjonsvitenskap
Per-Arne Pedersen, Mørkved, Læreutdanningen
Anders Østensen, Mosjøen, Informatikk
yes, I understand all of that, what I don't understand is that the intro to bash says it interprets one and one line
so i don't get how it can know, when the loop starts, that the file used at done is the one it should loop through, as I would then assume it did not yet know about it... but maybe that all changes when it is saved as a sh file or something
yeah well mentioning a C64 or Vic20 is somewhat embarrassing - what about an amiga with sidecar?
I think he's talking about the amiga 500.I had a Texas Instruments 16k computer in the eighties.
What’s an amiga?