Answers for "separate a file using a tag"

0

separate a file using a tag

cat file.txt | awk -v RS="your_tag" '{ print $0 > "structure" NR }'
 
 this tend to create empty files / useless files after the final tag, so remove them as below 
 $5==0 $5 is file size column, 0 is to empty sometime it may be 2,3 kb, add file size accrodingly 
 
 ls -ltr structure* | awk '{if($5==0) system("rm "$9)}'
Posted by: Guest on January-19-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language