我是shell脚本的新手。我需要读取csv页眉和页脚的shell脚本。 感谢
答案 0 :(得分:0)
快速,2文本文件操作的基本工具:sed和awk 你也可以使用grep很少或没有修改但只是捕捉信息
# print 1st and last line only (-n mean no print by default, p mean print)
sed -n '1p;$p' YourFile
#or
# print if 1st, print if last, delete line (no print)
sed -e '1p;$p;d' YourFile
用awk:
# print first, remind last line read, at the end print last know line
awk '1;{last=$0};END{print $0)' YourFile
# but you can work on content like
awk '1{for(f=1;f<=NF;f++)h[i]=$1};{last=$0};END{split($0,a);for( j in h) printf( "%d:%s -> %s\n", j, h[j], a[j])}' YourFile
这取决于你想做什么(下一个)