for2 728x90 Bash Script: How read file line by line (best and worst way) Input: $ cat sample.txt This is sample file This is normal text file Source: $ cat readfile.sh #!/bin/bash i=1; FILE=sample.txt # Wrong way to read the file. # This may cause problem, check the value of 'i' at the end of the loopecho "###############################" cat $FILE | while read line; do echo "Line # $i: $line" ((i++)) done echo "Total number of lines in file: $i" # The worst way to r.. 2014. 9. 19. FOR /F tokens and delims Step by step The general syntax of FOR /F commands, at least the part we are going to analyze, is: FOR /F "tokens=n,m* delims=ccc" %%A IN ('some_command') DO other_command %%A %%B %%CUsing an example, we are going to try and find a way to define values for tokens and delims. For our example, we are going to find out who is logged on to a computer with a specified IP address (like, say, one found in our firew.. 2011. 4. 5. 이전 1 다음 728x90 728x90