这是另一种方法,很适合与一些文本编辑器一起使用,这些编辑器无法正确地突出显示您创建的每个复杂代码。
read -r -d '' str < <(cat somefile.txt) echo "${#str}" echo "$str"