Friday 22 August 2014

UNIX: tr(trim) command

TRIM COMMAND (tr):

tr command can be used to trim the specified contents of a file.
Removing NULL from file:
tr command can be used to delete the NULL character from a file.
tr -d '\000' < Path/filename1.txt > Path/filename2.txt

Eg:

tr -d "\000" < /etl/IS/Data/check/filename1.txt > /etl/IS/Data/check/filename2.txt
Removing UNIX newline from file:

tr command can be used to delete the NewLine character from a file.
tr -d '\n' < Path/filename1.txt > Path/filename2.txt
Eg:
tr -d "\n" < /etl/IS/Data/check/filename1.txt > /etl/IS/Data/check/filename2.txt


filename1.txt and filename2.txt should be different. 

No comments:

Post a Comment