使用last和tr剪切行和列

时间:2013-03-04 23:14:20

标签: linux bash multiple-columns

用户从“最后”命令中选择要剪切的行以及哪些列 削减。除了使用变量之外,还使用'tr'来实现 修复白色空间中的所有差异。我尝试了下面的代码,但不知道我哪里出错了。

echo -n "What rows and columns would you like to cut: "
read before
read after
read stop
read start
last | head -n $before friend_list | tail -n $after | tr -d $start $stop

1 个答案:

答案 0 :(得分:0)

听起来就像你想要的那样:

last | head -n $after | tail -n $((after-before+1)) | cut -f $start-$stop

将从last行输出$before的子集到行$after,从列$start到列$stop