Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

tr unix use

# Operate a substitution in a file, for example changing spaces into tabs
cat myfile.txt | tr " " "	" > my_new_file.txt
# You can also operate a character substitution 
cat myfile.whatever | tr "[a-z]" "[A-Z]" > my_new_file.whatever
# another example, change tabs into new line characters 
#(convert tab-separated column into rows)
cat myfile.tsv | tr "	" "
" > my_new_file.txt
###---
###---
#I find it particularly useful to change IFS instead of using in-place sed like:
sed -i 's/ /	/g' myfile.txt

#Best!
 
PREVIOUS NEXT
Tagged: #tr #unix
ADD COMMENT
Topic
Name
3+6 =