Skip to main content
added 2 characters in body
Source Link
Graeme
  • 34.6k
  • 9
  • 90
  • 110

The following should work provided you don't have any underscores in the last part of any of the filenames (and nothing else in the directory that matches the glob):

for file in ????_??_??_*.txt; do
  echo cat "$file" ">>"$">>""${file%_*}.txttxt"
done

Remove the echo part and the quotes around the >> when you are sure you have what you want.

The following should work provided you don't have any underscores in the last part of any of the filenames (and nothing else in the directory that matches the glob):

for file in ????_??_??_*.txt; do
  echo cat "$file" ">>"${file%_*}.txt
done

Remove the echo part and the quotes around the >> when you are sure you have what you want.

The following should work provided you don't have any underscores in the last part of any of the filenames (and nothing else in the directory that matches the glob):

for file in ????_??_??_*.txt; do
  echo cat "$file" ">>""${file%_*}.txt"
done

Remove the echo part and the quotes around the >> when you are sure you have what you want.

Source Link
Graeme
  • 34.6k
  • 9
  • 90
  • 110

The following should work provided you don't have any underscores in the last part of any of the filenames (and nothing else in the directory that matches the glob):

for file in ????_??_??_*.txt; do
  echo cat "$file" ">>"${file%_*}.txt
done

Remove the echo part and the quotes around the >> when you are sure you have what you want.