Hello all,
Doing very tiny bash scripts, I seem to get down ok. But for some reason, the 'for x in `grep something... | cut .. ' stuff just doesn't stick. I have looked all over at samples and I always learn something new about sed or awk, or something new about piping stuff, but never seem to actually get it... so I thought I would post an example here of something I was trying to do the other day and see what people think. Thanks in advance!
I have a file with 200 names in it. I have manipulated it enough that I have almost all the fields filled with data. Either by using cut from another file or continuing to sed the thing to death, one field at a time. All of the fields are the same for all 200 users, so this works. My problem comes in where I need to pull a field (below, number 2.. the emailid) for all 200 lines and place it as the value for the 6th field (the quotes after displayname).
Code:
ca user1@email.com '12345' default displayName '' givenName xxx sn yyyy
(CreateAccount emailid 'password' default-class displayName-goes-between-the quotes... I am not concerned with anything after displayname yet)
So as an example, the script runs through the file, it pulls
user1@email.com and I get a line that looks like this
Code:
ca user1@email.com '12345' default displayName 'user1@email.com' givenName xxx sn yyyy
I hope I am explaining this correctly. I am sure there are a ton of ways to do it, and if they are easier, please let me know. I have messed around with
Code:
for x in (cat file1.txt | grep *???@*); do sed 's/\'\'/$x/g'
(I am doing this quickly and it was a couple of days ago.. so I am sure my regex stuff is wrong ;-), but at the time it was right... I just kept getting results like the same line 200 times, for every person).
Again, I am sure there are a couple of ways to do stuff like this... Thanks!