How to explort content from file into variable? [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • How do I assign the output of a command to a variable?

    1 answer




I need save into variable the file content (json string).



I try several methods, in particular:



#!/bin/bash

myjson=cat patch/file.jsn


but nothing not work.



How to correctly implement this task?










share|improve this question













marked as duplicate by muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 at 9:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
    – guiverc
    Nov 17 at 9:38

















up vote
0
down vote

favorite













This question already has an answer here:




  • How do I assign the output of a command to a variable?

    1 answer




I need save into variable the file content (json string).



I try several methods, in particular:



#!/bin/bash

myjson=cat patch/file.jsn


but nothing not work.



How to correctly implement this task?










share|improve this question













marked as duplicate by muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 at 9:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
    – guiverc
    Nov 17 at 9:38















up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • How do I assign the output of a command to a variable?

    1 answer




I need save into variable the file content (json string).



I try several methods, in particular:



#!/bin/bash

myjson=cat patch/file.jsn


but nothing not work.



How to correctly implement this task?










share|improve this question














This question already has an answer here:




  • How do I assign the output of a command to a variable?

    1 answer




I need save into variable the file content (json string).



I try several methods, in particular:



#!/bin/bash

myjson=cat patch/file.jsn


but nothing not work.



How to correctly implement this task?





This question already has an answer here:




  • How do I assign the output of a command to a variable?

    1 answer








bash environment-variables






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 17 at 9:34









Valentyn Hruzytskyi

2009




2009




marked as duplicate by muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 at 9:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 17 at 9:42


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
    – guiverc
    Nov 17 at 9:38
















  • 1




    mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
    – guiverc
    Nov 17 at 9:38










1




1




mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
– guiverc
Nov 17 at 9:38






mjson=`cat patch/file.jsn` (backticks cause the command's output to replace the command)
– guiverc
Nov 17 at 9:38












1 Answer
1






active

oldest

votes

















up vote
1
down vote













You can try this:



#!/bin/bash

myjson=$(cat patch/file.jsn)





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    You can try this:



    #!/bin/bash

    myjson=$(cat patch/file.jsn)





    share|improve this answer

























      up vote
      1
      down vote













      You can try this:



      #!/bin/bash

      myjson=$(cat patch/file.jsn)





      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        You can try this:



        #!/bin/bash

        myjson=$(cat patch/file.jsn)





        share|improve this answer












        You can try this:



        #!/bin/bash

        myjson=$(cat patch/file.jsn)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 at 9:39









        kukulo

        1,260417




        1,260417















            Popular posts from this blog

            How to send String Array data to Server using php in android

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Is anime1.com a legal site for watching anime?