Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

How do I use cut to make tab the delimiter?

Writer Matthew Martinez

I am working with the egrep command and I need to pair with the cut (and ONLY cut) command to change a ":" into a tab. For example change:

Blahblahblah:2000

to:

Blahblahblah 2000

I currently have this, but it turns the ":" into "/t" and not tab:

egrep -e "^[0-9]" *.txt | cut -d ":" --output-delimiter="/t" -f 1- > test.txt

2 Answers

Use this:

egrep -e "^[0-9]" *.txt | cut -d ":" --output-delimiter=$'\t' -f 1- > test.txt

should work in Bash.

4

Alternately, you can also use the tr command, if your need is to just replace the delimiter as follows

echo "Blahblahblah:2000" | tr ':' '\t'

You will get the following output

Blahblahblah 2000
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy