help with printing data
i have a data like
username1 number string -file1 -file2 . . -filen username2 number string -file1 -file2 . . -filen how can i just print files under specific usernames. i am asking user to enter username. |
In a multi-User environment, normally each User would just print their own files, without needing to specify their User name.
So please give us some understanding of the printing is set up on the system you are trying to use. |
From http://www.catonmat.net/blog/sed-one...ned-part-two/:
Quote:
Code:
read -p "Please enter the username: " ; sed -e '/./{H;$!d;}' -e 'x;/$REPLY/!d;' Hope it helps. |
Oh, print, not print. ;)
|
In that case, if I put this data:
Code:
username1 Code:
BEGIN { then run this sequence of commands, repeatedly, providing different User Names as input: Code:
read -p 'Please enter the User Name: ' user_name ; gawk -vuser_name="$user_name" -f show_file_names_by_username.awk < data.txt Code:
Please enter the User Name: username1 Code:
Please enter the User Name: username2 Code:
Please enter the User Name: username3 Hope this Helps! |
hmmmm ... I think kakaka is on the right track although I think it could be a little simpler:
Code:
awk 'BEGIN{ FS="\n";RS="^$\n"; printf "Please enter the User Name: "; getline uname < "-"}$1 ~ uname' file |
yeah i get it but actually according to question you are supposed to ask a number
|
Again you refer to this 'question' and if you do not spell out where this is coming from, everyone will assume this is homework and as per the LQ rules, we do not do homework.
|
All times are GMT -5. The time now is 05:41 PM. |