while read -r -d '' line; do # logic # use a second 'read ... <<< "$line"' if we need to tokenize the line done < <(find /path/to/dir -print0) 相关阅读:BashFAQ/020 - 如何找到并安全处理包含换行符、空格或两者的文件名? 同时从多个文件中读取内容 while read -u 3 -r line...
tokenize () { local GREP local ESCAPE local CHAR GREP='egrep -ao'ESCAPE='(\\[^u[:cntrl:]]|\\u[0-9a-fA-F]{4})'CHAR='[^[:cntrl:]"\\]'local STRING="\"$CHAR*($ESCAPE$CHAR*)*\""local NUMBER='-?(0|[1-9][0-9]*)([.][0-9]*)?([eE][+-]?[0-9]*)?'local KEYWO...
In practice, theIFSvariable is used to tokenize a string into fields based on the specified delimiter. To elaborate, this special shell variable determines how Bash recognizes word boundaries in strings. In this method, we’ll useIFSwith aforloop to iterate over different variables. Now, let’...
Shells read input up to an unquoted newline and then execute it. An unquoted backslash followed by a newline are discarded and cause the shell to wait for more input. The backslash and newline are discarded before the shell tokenizes the string, so long lines can be split anywhere outside...