testxlog

testxlog

Batch split text by line in LINUX system and name it with the content before TAB

1. TAB Separation#

  • Split files by line in LINUX system
  • Name each file based on the content before the TAB in each line
  • Only one command is needed
  • awk -F'\t' '{print > "" $1 ".txt"}' 000.txt
  • Here it is assumed that the file to be split is 000.txt
  • You can write the prefix for the split file names in quotes or leave it empty

2. Space Separation#

  • Split files by line in LINUX system
  • Name each file based on the content before the space in each line
  • Only one command is needed
  • awk '{for (i=1; i<=NF; i++) print $i " " $i > $1 ".txt"}' 000.txt
  • Here it is assumed that the file to be split is 000.txt
  • You can write the prefix for the split file names in quotes or leave it empty
  • photo by Nick Design(https://unsplash.com/@nickshuperdesign?utm_source=templater_proxy&utm_medium=referral&fit=crop&mask=corners) on Unsplash
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.