one-liner to delete a part of a column with matching pattern (sed/awk etc)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












A very generic question but I am looking for the simplest way solve this very quickly and efficiently

I have a file with a very large number of lines which looks like this



 451267 sample1.txt 
157444 sample2.txt
134864 sample2.txt


and I want result where the file(same or new) looks like



 451267 sample1 
157444 sample2
134864 sample2









share|improve this question









New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
    – Valentin B
    Oct 4 at 6:56















up vote
-1
down vote

favorite












A very generic question but I am looking for the simplest way solve this very quickly and efficiently

I have a file with a very large number of lines which looks like this



 451267 sample1.txt 
157444 sample2.txt
134864 sample2.txt


and I want result where the file(same or new) looks like



 451267 sample1 
157444 sample2
134864 sample2









share|improve this question









New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
    – Valentin B
    Oct 4 at 6:56













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











A very generic question but I am looking for the simplest way solve this very quickly and efficiently

I have a file with a very large number of lines which looks like this



 451267 sample1.txt 
157444 sample2.txt
134864 sample2.txt


and I want result where the file(same or new) looks like



 451267 sample1 
157444 sample2
134864 sample2









share|improve this question









New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











A very generic question but I am looking for the simplest way solve this very quickly and efficiently

I have a file with a very large number of lines which looks like this



 451267 sample1.txt 
157444 sample2.txt
134864 sample2.txt


and I want result where the file(same or new) looks like



 451267 sample1 
157444 sample2
134864 sample2






shell-script awk sed cut paste






share|improve this question









New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Oct 4 at 8:43





















New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Oct 4 at 6:46









A_Rahman

32




32




New contributor




A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






A_Rahman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
    – Valentin B
    Oct 4 at 6:56













  • 1




    Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
    – Valentin B
    Oct 4 at 6:56








1




1




Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
– Valentin B
Oct 4 at 6:56





Simple and fast with cut cut -d. -f1 filename. Of if you prefer awk -F. 'print $1' filename If you want to know more about string manipulation see: mywiki.wooledge.org/BashFAQ/100
– Valentin B
Oct 4 at 6:56











1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










The easiest way to do this is with sed I believe.



sed 's/.txt//g' file



This command replaces the pattern '.txt' with nothing.






share|improve this answer


















  • 1




    uuoc, better: sed 's/.txt//g' file
    – RoVo
    Oct 4 at 7:02










  • worked like a charm.Thanks both of you
    – A_Rahman
    Oct 4 at 7:12










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473149%2fone-liner-to-delete-a-part-of-a-column-with-matching-pattern-sed-awk-etc%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










The easiest way to do this is with sed I believe.



sed 's/.txt//g' file



This command replaces the pattern '.txt' with nothing.






share|improve this answer


















  • 1




    uuoc, better: sed 's/.txt//g' file
    – RoVo
    Oct 4 at 7:02










  • worked like a charm.Thanks both of you
    – A_Rahman
    Oct 4 at 7:12














up vote
0
down vote



accepted










The easiest way to do this is with sed I believe.



sed 's/.txt//g' file



This command replaces the pattern '.txt' with nothing.






share|improve this answer


















  • 1




    uuoc, better: sed 's/.txt//g' file
    – RoVo
    Oct 4 at 7:02










  • worked like a charm.Thanks both of you
    – A_Rahman
    Oct 4 at 7:12












up vote
0
down vote



accepted







up vote
0
down vote



accepted






The easiest way to do this is with sed I believe.



sed 's/.txt//g' file



This command replaces the pattern '.txt' with nothing.






share|improve this answer














The easiest way to do this is with sed I believe.



sed 's/.txt//g' file



This command replaces the pattern '.txt' with nothing.







share|improve this answer














share|improve this answer



share|improve this answer








edited Oct 4 at 7:57

























answered Oct 4 at 6:56









Panki

1909




1909







  • 1




    uuoc, better: sed 's/.txt//g' file
    – RoVo
    Oct 4 at 7:02










  • worked like a charm.Thanks both of you
    – A_Rahman
    Oct 4 at 7:12












  • 1




    uuoc, better: sed 's/.txt//g' file
    – RoVo
    Oct 4 at 7:02










  • worked like a charm.Thanks both of you
    – A_Rahman
    Oct 4 at 7:12







1




1




uuoc, better: sed 's/.txt//g' file
– RoVo
Oct 4 at 7:02




uuoc, better: sed 's/.txt//g' file
– RoVo
Oct 4 at 7:02












worked like a charm.Thanks both of you
– A_Rahman
Oct 4 at 7:12




worked like a charm.Thanks both of you
– A_Rahman
Oct 4 at 7:12










A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.












A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.











A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473149%2fone-liner-to-delete-a-part-of-a-column-with-matching-pattern-sed-awk-etc%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?