Reputation: 1
i have a file called file1 containing the following
firstname lastname location etc
second line
third line
i am using this code
read a b c < file1
echo $a $b $c
the output i am getting is
firstname lastname location etc
so my program is taking
a = firstname
b = lastname
c= location etc
how can i get my program to take
c= location etc second line third line
Upvotes: 0
Views: 47
Reputation: 5942
Reading your query you want to have everything in one line.
# read file in one variable
c=`cat file1`
# keep everything in a separate line
echo "$c"
# put everything in one line
echo $c
The last echo
will produce the output you have in your question:
firstname lastname location etc second line third line
Upvotes: 0
Reputation: 785376
You can use -d
flag in read
:
read -d '' a b c < file1
echo "$c"
location etc
second line
third line
Upvotes: 1