False King
False King

Reputation: 37

How to get rid of all of a single character from a string with cut

I'm trying to get rid of all of the "|" characters and add a space from an input file that is formatted like this: word|word|number

F=$(curl ftp://ip/pub/text.txt)

cut_stuff(){

# this is where I get confused
cut -d"|" -f "1-3"

}

for i in $F; do
echo $i | cut_stuff
done

Upvotes: 1

Views: 128

Answers (1)

James Brown
James Brown

Reputation: 37464

As requested, using cut:

$ echo 1\|2\|3 | cut -d \| --output-delimiter=" " -f 1-
1 2 3

Upvotes: 1

Related Questions