This tutorial explains Linux “unexpand” command, options and its usage with examples.
Description :
Convert spaces in each FILE to tabs, writing to standard output. With no FILE, or when FILE is -, read standard input.
Usage :
unexpand [OPTION]… [FILE]…
Options :
-a, –all
convert all blanks, instead of just initial blanks.
–first-only
convert only leading sequences of blanks (overrides -a).
-t, –tabs=N
set tabs N characters apart instead of the default of 8 (enables -a).
-t, –tabs=LIST
use comma separated LIST of tab positions (enables -a).
Examples :
1. Basic Example
$ cat -vet file2 One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$ One Two Three Four Five six seven$
By using the “cat -vet” option against file1, we can see that the tabs are represented by the “I^” character.The “$” denotes a line feed.
$ unexpand -a file2 > file3 $ cat -vet file3 One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$ One^ITwo^IThree^IFour^IFive^Isix^Iseven$
Hece the spaces are converted into tabs.
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Check Information Technology Books
- Check Linux Books
- Apply for Programming Internship
- Practice Programming MCQs