Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Remove characters between "-".

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Remove characters between "-".

#1 Post by hack3rcon »

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.

User avatar
Bloom
df -h | grep > 90TiB
df -h | grep > 90TiB
Posts: 504
Joined: 2017-11-11 12:23
Been thanked: 26 times

Re: Remove characters between "-".

#2 Post by Bloom »

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.

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Remove characters between "-".

#3 Post by hack3rcon »

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.

User avatar
Bloom
df -h | grep > 90TiB
df -h | grep > 90TiB
Posts: 504
Joined: 2017-11-11 12:23
Been thanked: 26 times

Re: Remove characters between "-".

#4 Post by Bloom »

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).

hack3rcon
Posts: 746
Joined: 2015-02-16 09:54
Has thanked: 48 times

Re: Remove characters between "-".

#5 Post by hack3rcon »

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.

Post Reply