niall_heavey> Hope this all makes sense!
Some but not all, since it is missing information
I'll work with what you gave me. I'll explain.
You mentioned the first 50 users.
You must have, then, a way to identify those users. Assuming a file list with each user name in each line, we will call that file userlist
Now we can start working
#! /bin/bash
# read each name and pass it to grep to create a different identity file log
while read name
do
# any line in yyy.csv that contains $name is gathered and sent to $name.csv
grep $name yyy.csv > $name.csv
done < userlist
or
#! /bin/bash
for name in $(cat userlist)
do
grep $name yyy.csv > $name.csv
done
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
niall_heavey> Would this be preferable as a csv file or should I use something else like txt or other?
An ASCII text file is the simplest
niall_heavey> Also, if there was two columns in this would it cause trouble?
Nope, grep looks for the term and if finds it, will send the whole line to the output of choice, in this case a file with the username
niall_heavey> Also, which would be best? The bash or shell? Or is there much of a difference?
Bash is the default shell for Ubuntu. There are many shells, Bash it one of the most popular.
niall_heavey> And finally, in both codes you use "name" do I use it as you have it or is it to signify something?
name is just a variable identifier, it is not a built-in keyword. You can use any identifier than makes sense to you, as long as it starts with an alphanumeric or underscore character
Don't forget the $ symbol in front when dereferencing it.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
#! /bin/bash
# read each name and pass it to grep to create a different identity file log
while read name
do
# any line in yyy.csv that contains $name is gathered and sent to $name.csv
grep $name yyy.csv > $name.csv
done < userlist
Just another quick question on this. If I want to read from the file yyy.csv if it is in another directory what syntax should I use?
If it was in terminal I would only need to go down one level (i.e. use cd ..) to get to the directory I want to use.
Any ideas?
Thanks,
N
Same thing. You can use an absolute pathe.i. /home/niall_heavey/logfiles/yyy.csv
or you can pass it a relative pathe.i ../yyy.csv
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218