How to convert a file with several spaces into a tab-delimited file?Comparing two text filesOnly delete files but not folders with rmHow do I transpose a row to a column in a tab-delimited file?How do I merge tab-delimited files?using awk inside expect programlist of pattern to be removed from the fileReplace all lines between two patterns (inclusive) with a file contentmerge two files with two common fieldshow can sed match pattern delete line plus one and insert diferent fileGrepping all strings on the same line
Why isn't a binary file shown as 0s and 1s?
Do medium format lenses have a crop factor?
Do Australia and New Zealand have a travel ban on Somalis (like Wikipedia says)?
Manager asking me to eat breakfast from now on
Who or what determines if a curse is valid or not?
May I use a railway velocipede on actively-used British railways?
Does unblocking power bar outlets through short extension cords increase fire risk?
Real orthogonal and sign
Could a US citizen born through "birth tourism" become President?
Why do the digits of a number squared follow a similar quotient?
How can I automate this tensor computation?
Are there any satellites in geosynchronous but not geostationary orbits?
How to tell readers that I know my story is factually incorrect?
Is it possible to have a career in SciComp without contributing to arms research?
Who determines when road center lines are solid or dashed?
Null expletive objects in Latin? "Cariotae cum ficis certandum habent" (Plin. Ep. 1,8)
Making a Dataset that emulates `ls -tlra`?
Locked-up DOS computer beeped on keypress. What mechanism caused that?
What's a German word for »Sandbagger«?
Pauli exclusion principle - black holes
Does 5e follow the Primary Source rule?
BritRail England Passes compared to return ticket for travel in England
I have found a mistake on someone's code published online: what is the protocol?
Applying for jobs with an obvious scar
How to convert a file with several spaces into a tab-delimited file?
Comparing two text filesOnly delete files but not folders with rmHow do I transpose a row to a column in a tab-delimited file?How do I merge tab-delimited files?using awk inside expect programlist of pattern to be removed from the fileReplace all lines between two patterns (inclusive) with a file contentmerge two files with two common fieldshow can sed match pattern delete line plus one and insert diferent fileGrepping all strings on the same line
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I had file1
:
MSTRG.10807.1 0.494311896511595 MID 0.423993026403461 2.39379412548345 1.99703339651136
MSTRG.10884.1 0.365770947942799 EARLY 1.46416917664929 1.16816186543633 0.689075392478972
MSTRG.10958.1 0.52855355823638 MID 0.885493751836316 2.28463841550375 1.26867555157512
I used command the sed 's/ /,/g' file1 > file2
and this produced file2
:
MSTRG.10807.1,,,0.494311896511595,,,MID,,,,0.423993026403461,,2.39379412548345,,,1.99703339651136
MSTRG.10884.1,,,0.365770947942799,,,EARLY,,1.46416917664929,,,1.16816186543633,,,0.689075392478972
MSTRG.10958.1,,,0.52855355823638,,,,MID,,,,0.885493751836316,,2.28463841550375,,,1.26867555157512
But I want a tab-delimited file.
command-line sed
add a comment |
I had file1
:
MSTRG.10807.1 0.494311896511595 MID 0.423993026403461 2.39379412548345 1.99703339651136
MSTRG.10884.1 0.365770947942799 EARLY 1.46416917664929 1.16816186543633 0.689075392478972
MSTRG.10958.1 0.52855355823638 MID 0.885493751836316 2.28463841550375 1.26867555157512
I used command the sed 's/ /,/g' file1 > file2
and this produced file2
:
MSTRG.10807.1,,,0.494311896511595,,,MID,,,,0.423993026403461,,2.39379412548345,,,1.99703339651136
MSTRG.10884.1,,,0.365770947942799,,,EARLY,,1.46416917664929,,,1.16816186543633,,,0.689075392478972
MSTRG.10958.1,,,0.52855355823638,,,,MID,,,,0.885493751836316,,2.28463841550375,,,1.26867555157512
But I want a tab-delimited file.
command-line sed
add a comment |
I had file1
:
MSTRG.10807.1 0.494311896511595 MID 0.423993026403461 2.39379412548345 1.99703339651136
MSTRG.10884.1 0.365770947942799 EARLY 1.46416917664929 1.16816186543633 0.689075392478972
MSTRG.10958.1 0.52855355823638 MID 0.885493751836316 2.28463841550375 1.26867555157512
I used command the sed 's/ /,/g' file1 > file2
and this produced file2
:
MSTRG.10807.1,,,0.494311896511595,,,MID,,,,0.423993026403461,,2.39379412548345,,,1.99703339651136
MSTRG.10884.1,,,0.365770947942799,,,EARLY,,1.46416917664929,,,1.16816186543633,,,0.689075392478972
MSTRG.10958.1,,,0.52855355823638,,,,MID,,,,0.885493751836316,,2.28463841550375,,,1.26867555157512
But I want a tab-delimited file.
command-line sed
I had file1
:
MSTRG.10807.1 0.494311896511595 MID 0.423993026403461 2.39379412548345 1.99703339651136
MSTRG.10884.1 0.365770947942799 EARLY 1.46416917664929 1.16816186543633 0.689075392478972
MSTRG.10958.1 0.52855355823638 MID 0.885493751836316 2.28463841550375 1.26867555157512
I used command the sed 's/ /,/g' file1 > file2
and this produced file2
:
MSTRG.10807.1,,,0.494311896511595,,,MID,,,,0.423993026403461,,2.39379412548345,,,1.99703339651136
MSTRG.10884.1,,,0.365770947942799,,,EARLY,,1.46416917664929,,,1.16816186543633,,,0.689075392478972
MSTRG.10958.1,,,0.52855355823638,,,,MID,,,,0.885493751836316,,2.28463841550375,,,1.26867555157512
But I want a tab-delimited file.
command-line sed
command-line sed
edited Jul 10 at 7:22
Eliah Kagan
86.6k22 gold badges241 silver badges383 bronze badges
86.6k22 gold badges241 silver badges383 bronze badges
asked Jul 10 at 7:15
Kousalya DeviKousalya Devi
263 bronze badges
263 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If you want the tab character, use t
as the replace pattern instead of ,
.
If you want just one tab (or comma) to replace multiple spaces, add +
after the space:
sed 's/ +/t/g' file1 > file2
add a comment |
Use tr
:
tr -s ' ' 't' < file1 > file2
-s, --squeeze-repeats
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that
character
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1157191%2fhow-to-convert-a-file-with-several-spaces-into-a-tab-delimited-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want the tab character, use t
as the replace pattern instead of ,
.
If you want just one tab (or comma) to replace multiple spaces, add +
after the space:
sed 's/ +/t/g' file1 > file2
add a comment |
If you want the tab character, use t
as the replace pattern instead of ,
.
If you want just one tab (or comma) to replace multiple spaces, add +
after the space:
sed 's/ +/t/g' file1 > file2
add a comment |
If you want the tab character, use t
as the replace pattern instead of ,
.
If you want just one tab (or comma) to replace multiple spaces, add +
after the space:
sed 's/ +/t/g' file1 > file2
If you want the tab character, use t
as the replace pattern instead of ,
.
If you want just one tab (or comma) to replace multiple spaces, add +
after the space:
sed 's/ +/t/g' file1 > file2
answered Jul 10 at 7:24
MelebiusMelebius
6,7535 gold badges27 silver badges49 bronze badges
6,7535 gold badges27 silver badges49 bronze badges
add a comment |
add a comment |
Use tr
:
tr -s ' ' 't' < file1 > file2
-s, --squeeze-repeats
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that
character
add a comment |
Use tr
:
tr -s ' ' 't' < file1 > file2
-s, --squeeze-repeats
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that
character
add a comment |
Use tr
:
tr -s ' ' 't' < file1 > file2
-s, --squeeze-repeats
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that
character
Use tr
:
tr -s ' ' 't' < file1 > file2
-s, --squeeze-repeats
replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that
character
answered Jul 10 at 9:07
pLumopLumo
10.1k21 silver badges48 bronze badges
10.1k21 silver badges48 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1157191%2fhow-to-convert-a-file-with-several-spaces-into-a-tab-delimited-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown