I've got a file CSV with 3 column
name,surname,group
if one of the column has got a space like
Davide,Super Dooper,Group
I cannot use it in a for loop
for i in `cat list.csv` ; do echo $i ; done
the result is
Davide,Super
Dooper,Group
how can I have all inone line?
Really thanks.
You should look at awk for this, for awk can handle differ column
separators
Kind regards,
Jan Gerrit
NOTE: Posting from groups.google.com (or some web-forums) dramatically
reduces the chance of your post being seen. Find a real news server.
>I've got a file CSV with 3 column
>name,surname,group
Sounds like a homework problem. Clue: comma separated.
>if one of the column has got a space like
>Davide,Super Dooper,Group
>I cannot use it in a for loop
and you didn't read the 'bash' man page - about shell grammar.
The list of words following in is expanded, generating a list of
items. The variable name is set to each element of this list in
turn, and list is executed each time.
There's more to that explanation.
>how can I have all inone line?
What did your instructor suggest? If this isn't a homework problem,
start by reading the bash man page (not the most helpful document),
the HOWTO:
-rw-rw-r-- 1 gferg ldp 31540 Jul 27 2000 Bash-Prog-Intro-HOWTO
and two marvelous documents from the Linux Documentation Project at
http://tldp.org/guides.html
* Bash Guide for Beginners
* Advanced Bash-Scripting Guide
A key to programming is to know what the material you are working with
actually looks like. For your example, I'd probably use 'cut'
[compton ~]$ whatis cut
cut (1) - remove sections from each line of files
[compton ~]$
directly, and not in a loop. 'awk' and 'sed' might also be useful,
but it depends on what you are actually trying to do.
[compton ~]$ whatis awk sed
awk (1) - pattern scanning and processing language
sed (1) - a Stream EDitor
[compton ~]$
Old guy
Check out the environment variable $IFS
(Internal Field Separator) in the bash man.