Search code examples
bashcut

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


Solution

  • As requested, using cut:

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