smart grouping shorten long command line 2

June 19th, 2007 mysurface Posted in curly brackets, Symbol, tar | Hits: 50984 | 1 Comment »

This post is to illustrate additional usage of curly brackets { } for range of numbers, continues from smart grouping shorten long command line.

Let say you have a list of logs where you want to pick a range of logs for analysis, the sample log files shows as bellow


tcp_06062007_1.txt
...
tcp_06062007_180.txt
tcp_06062007_181.txt
tcp_06062007_182.txt
...
tcp_06062007_230.txt

In order to archive logs from range 182 until 192, you do this

tar cjvf tcp_log.tar.bz2 tcp_06062007_{182..192}.txt

Remember DON’T use square bracket [ ] , square bracket is for character block, where by doing [189-192] will means 1 or 8 or 9 or 2 instead of the intended range from 182 to 192.

[中文翻译]

One Response to “smart grouping shorten long command line 2”

  1. You should really control the remarks here

Leave a Reply