Remove characters between "-".

Need help with C, C++, perl, python, etc?

Remove characters between "-".

Postby hack3rcon » 2020-10-28 09:30

Hello,
I have a lot of names with Date characters front of them:
Code: Select all
Char1   2020-10-28
Char2   2020-10-28
Char3   2020-10-28
Char4   2020-10-16
Char5   2020-10-28
Char6   2020-10-26

I want to have a Bash script that remove all these dates.

Thank you.
hack3rcon
 
Posts: 468
Joined: 2015-02-16 09:54

Re: Remove characters between "-".

Postby Bloom » 2020-10-28 10:44

If data.txt contains your data, just do:
Code: Select all
cut -d " " -f 1 data.txt

If you want to save the output, add '>newfile.txt' after data.txt.
User avatar
Bloom
 
Posts: 302
Joined: 2017-11-11 12:23

Re: Remove characters between "-".

Postby hack3rcon » 2020-11-03 12:03

Bloom wrote:If data.txt contains your data, just do:
Code: Select all
cut -d " " -f 1 data.txt

If you want to save the output, add '>newfile.txt' after data.txt.

Not worked.
hack3rcon
 
Posts: 468
Joined: 2015-02-16 09:54

Re: Remove characters between "-".

Postby Bloom » 2020-11-03 12:48

If in front of the dates, a tab is present, replace the -d " " by -d\t or remove the option (tab is the default separator for cut).
User avatar
Bloom
 
Posts: 302
Joined: 2017-11-11 12:23

Re: Remove characters between "-".

Postby hack3rcon » 2020-11-03 17:52

Bloom wrote:If in front of the dates, a tab is present, replace the -d " " by -d\t or remove the option (tab is the default separator for cut).

Thank you.
It was a tab and
Code: Select all
cut -f 1 "File Name"
solve it.
hack3rcon
 
Posts: 468
Joined: 2015-02-16 09:54


Return to Programming

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable