Grizzly521
Technical User
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:
who >> who.txt
A line of text looks like:
Username pts/## otherdata
So Im trying to get the usernames which on my system are always seven characters. Then store them as $var, then run
MyScript $var
Then get the username off of the next line, repeat.
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!
The text file is generated by:
who >> who.txt
A line of text looks like:
Username pts/## otherdata
So Im trying to get the usernames which on my system are always seven characters. Then store them as $var, then run
MyScript $var
Then get the username off of the next line, repeat.
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!