Linked Questions
11 questions linked to/from Storing output of command in shell variable
129
votes
3
answers
397k
views
How can I assign the output of a command to a shell variable?
I want to assign the result of an expression
(i.e., the output from a command)
to a variable and then manipulate it – for example,
concatenate it with a string, then echo it.
Here's what I've got:
#!/...
6
votes
2
answers
52k
views
How to grab output from command in shell script [duplicate]
I'm trying to write a shell script in RHEL which will execute grub-md5-crypt and the user will type their password.
Now the problem is how can I grab the encrypted md5 hash displayed to the user in ...
0
votes
2
answers
30k
views
curl command output in a variable [duplicate]
I am connecting to mySQL database using a shell script. After connecting to the mySQL database, I execute a query. The query gives me 300,000 URLs as the result.
For each of the 300,000 URLs I need ...
1
vote
2
answers
24k
views
Read the output of a command into a variable [duplicate]
I am making a bash script but I'm totally new and got lost.
I've made this code
cat * | grep "|*parameter1*|" | grep "|*parameter2*|" | cut -f 8,11,12,15,21,23,34 -d "|" | wc -l
which works just ...
2
votes
1
answer
10k
views
How to put value of echo pipe netcat commands into variable [duplicate]
I have this command succession:
echo -ne "/dev/shm/test.sh" | netcat 89.196.167.2 4567
and let's say it return a string like, for example "Hello...bla".
On the 89.196.167.2 system, I have made a ...
3
votes
1
answer
7k
views
setting output of a command to a variable [duplicate]
How can I put the output of head -15 textfile.txt to a variable $X to use it in an if command like this:
if $X = 'disabled' then
?
1
vote
1
answer
2k
views
How to put a command's result into a variable? [duplicate]
Possible Duplicate:
Storing output of command in shell variable
How can I put the result of jps | awk '$2~/Bootstrap/{print $1}' into a variable so that I can use with other commands?
-1
votes
1
answer
4k
views
How do I set an environment variable in the shell to be result of python script? [duplicate]
If I run
export TEST=script.py
echo $TEST
It outputs script.py
script.py code:
return 5
can TEST be set to 5? Obviously script will do something in future not just return a number
47
votes
3
answers
291k
views
How to get IP Address using shell script? [duplicate]
Want to get the IP address using Shell script. Without knowing the eth0 or eth1 or eth2 How to get the particular IP address.
I am not interest to get localhost address, want to get private IP ...
4
votes
3
answers
6k
views
How to pipe output of find as input for diff?
This is a basic question regarding bash but I could not find a solution.
I have many subdirectories with identically named files and I want to compare all of them for identity.
I can return list of ...
1
vote
1
answer
4k
views
How do I set a bash variable that contains another variable? [duplicate]
I am trying to set the variable service to be the value of
var1=first/second
echo $var1 | cut -d '/' -f 1
var2=$var1 | cut -d '/' -f 1"
echo $var2
The result of echo $var1 | cut -d '/' -f 1 is "...