one-liner to delete a part of a column with matching pattern (sed/awk etc)
Clash 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
shell-script awk sed cut paste
New contributor
add a comment |Â
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
shell-script awk sed cut paste
New contributor
1
Simple and fast with cutcut -d. -f1 filename
. Of if you preferawk -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
add a comment |Â
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
shell-script awk sed cut paste
New contributor
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
shell-script awk sed cut paste
New contributor
New contributor
edited Oct 4 at 8:43
New contributor
asked Oct 4 at 6:46
A_Rahman
32
32
New contributor
New contributor
1
Simple and fast with cutcut -d. -f1 filename
. Of if you preferawk -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
add a comment |Â
1
Simple and fast with cutcut -d. -f1 filename
. Of if you preferawk -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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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
add a comment |Â
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.
The easiest way to do this is with sed I believe.
sed 's/.txt//g' file
This command replaces the pattern '.txt' with nothing.
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
add a comment |Â
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
add a comment |Â
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.
A_Rahman is a new contributor. Be nice, and check out our Code of Conduct.
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
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
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
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
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
1
Simple and fast with cut
cut -d. -f1 filename
. Of if you preferawk -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