K
K
Konkase2014-10-23 08:17:34
bash
Konkase, 2014-10-23 08:17:34

How to assign variables to some words of a string in a bash loop?

Good afternoon!
Sometimes you need to pull out some words from the lines of a file, usually I do it like this:

cat ./file | while read line; do
  f=`echo "$line" | cut -f1 -d":"`
  s=`echo "$line" | cut -f2 -d":"`
  t=`echo "$line" | cut -f3 -d":"`
done

And already with these variables I work.
Is there an easier way to assign variables?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question