I got a lot of files with the following format:2014_04_01_11.txt2014_04_01_12.txt2014_04_01_13.txt2013_03_25_12.txt2013_04_29_15.txtI would like to tar all theses files into an archive 20?? _ ?? _ ??**.tar.gz.My actual command is:find . -name '????_??_??_*.txt' | tar ...I don't know how to define dynamically the name of the archive.
tar specific files based on a pattern
shell;files;wildcards;tar
This is very simple:tar -cvzf 2014_04_01.tar.gz 2014_04_01_??.txtUpdateTo do this for multiple dates (GNU find):find . -maxdepth 1 -name '????_??_??_??.txt' |  cut -d_ -f 1-3 |  sort -u |  while read date; do    tar -cvzf $date.tar.gz $date_??.txt  done