A
ally100
Guest
Hi all,
I have a text file containing hundreds of lines and I am trying to retrieve and print just the account names held in this text file.
Using grep -n '^user' filename.txt I can see that one of the accounts called 'user' is first word on one of three lines. The one I'm interested in is line 124. Now i want to be able to just print the account name user and nothing else.
Using this command - grep '^user' filename.txt , I get the following output;
user pts/1 adsl-194-162-fix Thu Jul 9 08:40:04
(note there are about 2 or 3 tabbed spaces between user and pts/1)
So my question is;
A) How do i limit the output to just line 124?
B) How do i print just the first word 'user' and not the remainder of the line?
C) I also need to replicate this for 2 other accounts, can this all be accomplished in one line?
Many thanks in advance
Ally.
I have a text file containing hundreds of lines and I am trying to retrieve and print just the account names held in this text file.
Using grep -n '^user' filename.txt I can see that one of the accounts called 'user' is first word on one of three lines. The one I'm interested in is line 124. Now i want to be able to just print the account name user and nothing else.
Using this command - grep '^user' filename.txt , I get the following output;
user pts/1 adsl-194-162-fix Thu Jul 9 08:40:04
(note there are about 2 or 3 tabbed spaces between user and pts/1)
So my question is;
A) How do i limit the output to just line 124?
B) How do i print just the first word 'user' and not the remainder of the line?
C) I also need to replicate this for 2 other accounts, can this all be accomplished in one line?
Many thanks in advance
Ally.