Results 1 to 2 of 2
Hi Im trying to extract the first seven characters of everyline of a file, then set those seven characters as a variable.
The text file is generated by:
Code:
who ...
- 10-19-2009 #1Just Joined!
- Join Date
- Oct 2009
- Posts
- 9
Extract First Seven Characters
Hi Im trying to extract the first seven characters of everyline of a file, then set those seven characters as a variable.
The text file is generated by:
So Im trying to get the usernames which on my system are always seven characters. Then store them as $var, then runCode:who >> who.txt
Then get the username off of the next line, repeat.Code:MyScript $var
Another way would be to extract everything up to the first space character.
Ive been trying to get this done but I always end up just extracting the whole line.
Any help would be great.
Thanks!
- 10-19-2009 #2
You can do something like this:
Or play with who -q if your who program supports that option.Code:who | while read u j; do : # do something with "$u" here done


Reply With Quote