Results 1 to 4 of 4
I have been playing around with a script for a few hours and now I need to be able to output the lines in a text file one by one ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-09-2010 #1
- Join Date
- Dec 2010
How to read a line from a txt file in a script?
What it gonna do is to read a log file and grep the usernames, then write them to a file, and then run one script for each user, to search for more information about them in the log.
But I don't know how to output a single line from a file, and google does not return any solution.
- 12-09-2010 #2
- 12-10-2010 #3
Another option, if you need to break out this loop for some reason, would be to open the file:
exec 5<$FILENAME # That's basic redirection syntax: $FILENAME is opened for reading and bound to file descriptor 5. "exec" is a shell built-in which applies this redirection to the shell's session. #To read a line from the open file, just redirect the input of "read" to FD #5... read x <&5 #To close the file, there's the following syntax. You can think of it as "redirect 5 from nothing"... exec 5<&-
- 12-11-2010 #4