问题描述
我正在使用此代码
cut -c1 | tr -d '\n'
基本上取并打印出每一行的第一个字母。问题是,我需要在结尾处换行,但仅在结尾处,在单词“caroline”之后(这些是 testfile
的内容)不能使用 AWK、basename、grep、egrep、fgrep 或 rgrep
解决方法
尝试使用 awk
实用程序,如下所示:-
awk -F\| '$1 > 0 { print substr($1,1,1)}' testfile.txt
,
使用回声
echo $( cut -c1 | tr -d '\n' ) \n
,
cut -c1 | tr -d '\n'; echo -e '\n'