Replace spaces characters by a hard tab in a 6 GB file on Linux
I have a vi command that replaces spaces characters by a hard tab:
vi myfile.txt
: # To go to the last line
1,$s/ /\t/g # Then I type in this to开发者_JS百科 replace spaces by a tab
How can I do it with AWK or sed?
Unless you strictly want sed
/awk
, tr
is the best option for it:
tr ' ' '\t' < inputfile > outputfile
Almost the same thing works with sed
, just use a real tab instead of \t
:
$ sed 's/ / /g' < input_file > output_file
# a tab ---^^
If you're doing this from the bash command line then you'll need to do a Ctrl-VTab pair to get a tab.
精彩评论