Redirect Output In Variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Redirect Output In Variable
# 1  
Old 08-02-2006
Redirect Output In Variable

how make assign the output of the command (for example: grep "file" "string" ) in a variable ($name)?

i thing how put the result of the command (grep , cut, find ecc) in a variable..

IT's Possible ??
# 2  
Old 08-02-2006
Use backquotes `` to assign output of a command to a var, like this:
Code:
$ a=`grep "WINDOWS" str2`
$ echo $a
test line WINDOWS test line

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirect script output to a file and mail the output

Hi Guys, I want to redirect the output of 3 scripts to a file and then mail the output of those three scripts. I used below but it is not working: OFILE=/home/home1/report1 echo "report1 details" > $OFILE =/home/home1/1.sh > $OFILE echo... (7 Replies)
Discussion started by: Vivekit82
7 Replies

2. Shell Programming and Scripting

How to redirect output of a command to a variable during ftp mode?

Hi, How can I redirect the output of a following command to a variable. ftp myservername ftp> user (username) guptaji 331 Password required for guptaji. Password: ftp> size /home/salil/abc.dat ftp> a='size /home/salil/abc.dat' ?Invalid command I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies

3. Shell Programming and Scripting

How to redirect 'crontab' output to a variable?

I'm trying to redirect the output of crontab to a variable named "crontab_status" as below: crontab_status=$(crontab -l) executing the script is not redirecting to the variable. Please help! (6 Replies)
Discussion started by: mjavalkar
6 Replies

4. Shell Programming and Scripting

script to mail monitoring output if required or redirect output to log file

Below script perfectly works, giving below mail output. BUT, I want to make the script mail only if there are any D-Defined/T-Transition/B-Broken State WPARs and also to copy the output generated during monitoring to a temporary log file, which gets cleaned up every week. Need suggestions. ... (4 Replies)
Discussion started by: aix_admin_007
4 Replies

5. Shell Programming and Scripting

Redirect output from SQL to unix variable

Hi, I have a requirement to store oracle sqlplus output to some unix variable, count the records and then print the output on the screen. Can you please point me to any sample program for reference purpose. Thanks a lot for your time. (0 Replies)
Discussion started by: bhupinder08
0 Replies

6. Shell Programming and Scripting

output redirect

Hi i am compiling a source code by make command. i want to redirect the output of make to a file but at the same time i want to see the output in terminal. how to do this ?. please suggest your idea. thanks in advance. Saravana ---------- Post updated at 05:24 PM ----------... (2 Replies)
Discussion started by: tsaravanan
2 Replies

7. Shell Programming and Scripting

Redirect Output

Hi, I would like to list files: ls *.hdf But I would like a copy of the output directed to the screen, but also APPENDED to a text file: test.txt I have tried: ls *.hdf | tee test.txt However, that will just write over everything already existing in test.txt. How can I append the... (1 Reply)
Discussion started by: msb65
1 Replies

8. Shell Programming and Scripting

redirect the grep output into the variable

i want to redirect the grep output into the variable but i am not able to get it i tried veri=`grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1` vari=$(grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1) BUT NOT... (1 Reply)
Discussion started by: mail2sant
1 Replies

9. Shell Programming and Scripting

awk redirect output to shell variable

I'm trying to redirect awk's output to a BASH variable. Currently the statement looks like this options=`awk '{ while (i < NF) { print $i; ++i } }' answer but for some reason that makes $options look like this: 1 2 3 4 1 2 3 Now, the input file 'answer' is taken from a dialog... (3 Replies)
Discussion started by: dhinge
3 Replies

10. UNIX for Dummies Questions & Answers

redirect command output to variable

Hi, I am looking for a way to redirect the result from a command into a variable. This is the scenario. Using the find command I will be getting multiple records/lines back. Here is the command I am using: find /”path”/ -name nohup.out -print This now is giving me the paths and file... (1 Reply)
Discussion started by: hugow
1 Replies
Login or Register to Ask a Question