Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 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.
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<&-