Linux / UNIX Tech Support Forum
This is a discussion on Shell Script for Searching a String within the Shell scripting forums, part of the Development/Scripting category; Hello I want to get the value of extension_dir from php.ini grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini This returns extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello
I want to get the value of extension_dir from php.ini grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini This returns extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" I just want /usr/local/lib/php/extensions/no-debug-non-zts-20060613 only. My question is How can I search for that and extract it? I also need to assign it to a vairable Thanks |
| Sponsored Links | ||
|
|
|
|||
|
Thank you
root@core2quad2 [~]# grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2 "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" root@core2quad2 [~]# It is displaying the correct value. One more question How can I assign this value to a variable ? Code:
PATH=grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2 echo $PATH grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2 |
|
||||
|
Code:
VAR=$(grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2) echo $VAR export PATH=$PATH:$VAR echo $PATH
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Quote:
Thank you I have one more problem Code:
VAR=$(grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2) echo "Extension Folder is " $VAR wget www.mysite.com/loaders.zip unzip loaders.zip mv * $VAR But here it gives mv: target `"/usr/local/lib/php/extensions/no-debug-non-zts-20060613"' is not a directory I assumge, I need to remove the " " from the starting and ending. How can I do that ? |
|
|||
|
I found this is what I need
VAR=$(grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2) echo "Extension Folder is " echo "$VAR" | tr '"' ' ' Just wanted to know, how can I assign the output of the last echo command to another variable ? |
|
||||
|
Quote:
Code:
VAR=$(grep -i /usr/local/lib/php/extensions /usr/local/lib/php.ini | cut -d'=' -f2) echo "Extension Folder is $VAR"
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| cut , grep , php , php.ini , shell scripting , string |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binary Conversion Of Shell Script (shell script compiler) | chandanperl | Shell scripting | 3 | 29-07-2008 10:22 AM |
| Shell Script Searching For a Record In The File | vinz4ever | Shell scripting | 1 | 11-05-2008 07:35 PM |
| split files by specifying a string (bash shell) | vikas027 | Shell scripting | 4 | 01-11-2007 04:22 PM |
| example for string connect to a command. | ryan | Shell scripting | 2 | 22-02-2005 01:05 PM |
| searching for bad words script | marinm | Shell scripting | 1 | 03-02-2005 04:32 PM |