Solved

Grep file content into variable while retaining returns in bash

Posted on 2009-03-29
3
1,470 Views
Last Modified: 2013-12-26
I'm using grep on a file and trying to parse the out put into a variable :

value=`grep "value" /file`
echo $vaule

But this returns the content of the file on one line it doesn't respect the returns at the end of each line. How can I fix this?
0
Comment
Question by:TotallyMe
3 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 500 total points
ID: 24015830
You need quotes

echo "$value"
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 24015854
can you give example ?
0
 

Author Closing Comment

by:TotallyMe
ID: 31564176
That was easier than expected :)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question