dd
The dd
utility can convert input text to output text in a variety of ways. It is helpful to look at the manual (using man dd
) because there are many options for this utility.
This command is also discussed in FIXTHIS Section 21.6 and 21.13 of the Unix Power Tools.
Here are two brief examples, of how dd
can be used to transform plain text into uppercase text or into lowercase text.
Converting text into uppercase (notice the option conv=ucase
)
echo "Greetings from The Data Mine\nHow about that?\nThat was cool" | dd conv=ucase status=none
Converting text into lowercase (this time using the option conv=ucase
)
echo "Greetings from The Data Mine\nHow about that?\nThat was cool" | dd conv=lcase status=none
The option status=none
tells dd
that we do not want to see the status output, which gives information about the operation of dd
. If you remove the option status=none
like this:
echo "Greetings from The Data Mine\nHow about that?\nThat was cool" | dd conv=ucase
you will see output like this:
GREETINGS FROM THE DATA MINE
HOW ABOUT THAT?
THAT WAS COOL
0+1 records in
0+1 records out
59 bytes transferred in 0.000019 secs (3105263 bytes/sec)
but please note that only the first three lines are the output from dd
. If you want to convince yourself of this, you can send the output text to a file, like this:
echo "Greetings from The Data Mine\nHow about that?\nThat was cool" | dd conv=ucase >myoutputfile.txt
You will see these 3 lines of status output in the terminal:
0+1 records in
0+1 records out
59 bytes transferred in 0.000284 secs (207746 bytes/sec)
but the actual converted text will be in the file called myoutputfile.txt
that you created:
cat myoutputfile.txt
displays the contents of the file:
GREETINGS FROM THE DATA MINE
HOW ABOUT THAT?
THAT WAS COOL