我有一个文件,格式是:
⌚..⌛ watch..hourglass
⌨️ keyboard
⏏️ eject button
其中一些行包含两个条目。我想将2条条目分成2行,如下所示:
⌚ watch
⌛ hourglass
⌨️ keyboard
⏏️ eject button
有什么快速的方法吗?
#!/usr/bin/env bash
wget -O output.txt http://www.unicode.org/Public/emoji/6.0/emoji-data.txt
sed -i '/^#/ d' output.txt # Remove comments
sed -i 's/.*(//' output.txt # Remove columns not needed
sed -i 's|[(),]||g' output.txt # Remove brackets around emoji
sed -i 's/\(.*[^ ]\)[ ]*\(.*\)/\2 \1/' output.txt # Move first column to last
sed -i '/^$/d' output.txt # Remove blank lines
the @RomanPerekhrest的答复如下(答复已更新):
↔️..↙️ left-right arrow..down-left arrow
↩️..↪️ right arrow curving left..left arrow curving right
⌚..⌛ watch..hourglass done
⌨️ keyboard
它在手表/沙漏上工作,但不像上面的(?)
发布于 2017-08-21 15:46:24
发布于 2017-08-21 16:39:27
另一个sed
版本,基于齐柏林飞艇回答,但更简单和对齐-注意,unicode并不总是单一字符。用gnu sed
进行测试。
sed 's/\.\.\([^ ]*\) *\(.*\)\.\./\t\2\n \1\t/'
输出:
↔️ left-right arrow
↙️ down-left arrow
↩️ right arrow curving left
↪️ left arrow curving right
⌚ watch
⌛ hourglass done
⌨️ keyboard
https://unix.stackexchange.com/questions/387455
复制相似问题