Sample Header Ad - 728x90

Get rid of UNIX redirection newly created file without using rm

0 votes
1 answer
71 views
Using below function to filter out text file and organize to new format. Using unix redirection > command to create new files. **How can I get rid of creating all new files** > (e.g. ${file}_final_1.txt,${file}_only_${pattern}.txt) **without deleting it afterword using rm command ?**
filter(){
  cat ${file}_1.txt | grep -v ${pattern} > ${file}_final_1.txt                            
  cat ${file}_1.txt | grep ${pattern} > ${file}_only_${pattern}.txt                        
  cat ${file}_only_${pattern}.txt  | nawk -F '|' '{ print $NF}' > ${pattern}_TS.txt        
  paste ${pattern}_TS.txt ${file}_only_${pattern}.txt > ${pattern}_TS_file.txt
  cat ${pattern}_TS_file.txt | grep "|${DT}|" | grep ${pattern} | sort -r | head -1 > ${file}_f.txt
  cat ${file}_f.txt >> ${file}_final_1.txt
  dos2unix ${file}_final_1.txt ${file}_final.txt
}
Asked by Rocky (3 rep)
Aug 23, 2022, 02:42 PM
Last activity: Aug 23, 2022, 03:09 PM