尝试显示文件的第二行,然后将其转换为大写。
尝试了 head 2 文件 | tr [a-z] [A-Z]
.
最佳答案
sed -n '2{p;q;}' file.txt | tr '[:lower:]' '[:upper:]'
或
awk 'NR==2{print toupper($0);exit}' file.txt
或
head -n2 file.txt | tail -n1 | tr '[:lower:]' '[:upper:]'
[:lower:] [:upper:]
的形式是推荐的方式(POSIX
类)
关于linux - 显示文件的特定行,然后在 linux 中转换为大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13300020/