But the $Name is inputed by me!! The code is for it to look for the name in the file funcionarios.csv and if it's there in output's the code...
I guess instead of looking into Scrutinizer's suggested script, you want an explanation of why your script is not working.
I'll start out with your script and csv file that has only the first two records. I've added a couple of "echo" statements in your script to aid in debugging. They are shown in red below.
The csv file looks like this -
Now run the script. My shell is Bash, btw.
Here's what happened.
(i) I entered the name "Jose Antonio Borges".
(ii) It printed the value of name "Jose Antonio Borges" at line 4.
(iii) It fetches value of prev at line 5.
(iv) It prints the value of prev at line 6. Note this value of prev:
Is this what you wanted ??
Or did you want the value "001op;Jose Antonio Borges;Rua de Cima, 7, Lisboa" while processing line 1.
And "002op;Silvia Maria;xxxx xxxx, 8, Lisboa" while processing line 2.
If that's the case, then you don't have to do that. It's an unnecessary and convoluted way of doing things. You don't have to split the line twice, you can read the line and split it into tokens while reading itself. Which is what Scrutinizer is trying to tell you.
(v) The value of "linha" is the same as "prev".
(vi) And because "linha" has been botched up, the value of "fun" is incorrect too.
You probably wanted the value of "fun" to be:
- "Jose Antonio Borges" while processing line 1.
- "Silvia Maria" while processing line 2.
Have a look at Scrutinizer's script. It reads a line, breaks it up into appropriate tokens (while reading itself) and then compares the 2nd token with the name that you input.
Hello all,
I have some weird problem that kinda baffles me. Say I have the following test file:
claudia:~/tmp$ cat testfile.txt
This is a test line
This is the second test line
And yeah, this is the third test line
Then say I want to tail the file, grep for the word "third" then... (7 Replies)
Hi
Can anyone what I am doing wrong while using cut command.
for f in *.log
do
logfilename=$f
Log "Log file Name: $logfilename"
logfile1=`basename $logfilename .log`
flength=${#logfile1}
Log "file length $flength"
from_length=$(($flength - 15))
Log "from... (2 Replies)
I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250.
I would like to join all 250 of them together tail by tail as follows. For example
stat.1000
a b c
d e f
stat.1001
g h i
j k l
So that my output... (2 Replies)
I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
I am using : << cut / cut to comment out block of code.
Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines.
The "warning " is at last line of script.
done < results
169 echo "END read all positioning parameters"
170... (8 Replies)