![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need to get pid of a process and have to store the pid in a variable | samudha | UNIX for Dummies Questions & Answers | 7 | 08-05-2008 12:24 AM |
| How to store the sql query's output in a variable | venkatesh_sasi | Shell Programming and Scripting | 4 | 01-17-2008 10:03 PM |
| store the first line of a file in a variable | dineshr85 | Shell Programming and Scripting | 0 | 12-06-2007 01:41 AM |
| To store the output in a variable | Sudhakar333 | Shell Programming and Scripting | 2 | 07-10-2007 05:45 AM |
| store awk results in a variable | forever_49ers | Shell Programming and Scripting | 1 | 09-19-2006 07:51 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
How to Store command O/P to a variable...
Hi all..
I got a problem.. Its easy to redirect o/p to a file.. But Is it possible to redirect the O/P to a variable? For example: I've a command in my script: Code:
string1=cut -d ':' -f2 file.txt Code:
echo $string1 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
#!/bin/ksh string1=$(cut -d ':' -f2 file.txt) |
|
#3
|
|||
|
|||
|
Quote:
syntax error at line 5: '(' unexpected |
|
#4
|
|||
|
|||
|
what is the shell and the OS version
|
|
#5
|
|||
|
|||
|
Quote:
#!/bin/ksh str1=`cut -d":" -f2 file.txt echo $str1 This will work i hope. Thanks Namish |
|
#6
|
|||
|
|||
|
Sun OS 5.8 and bash
My Unix Version is Sun OS 5.8 and working in bash.
Thanks. |
|
#7
|
|||
|
|||
|
Did you try what i suggested above.That will work for you. Thanks Namish |
|||
| Google The UNIX and Linux Forums |