I make this script that uses "strace" to trace programs. The script looks for files that the program opens. It looks like this
I want to extract the path without the quotes, preferably using grep and cut, but it can be also sed or awk (I just don't know these much). I worked out a regular expression egrep -o "\(\"[^\"]*\"," | cut -f 2 -d \" but then I realized the path can contain characters like " as well.
I thought the solution could look something like this egrep -o "\(\"[^{[^\\]\",[:space:]}]*\"," (any characters except string "[^\\]\",[:space:]" and these characters repeating)... Because I found out that strace doesn't work correctly if "\" without quotes is at the end of the file. So I thought I could use it as a benefit. However, it doesn't work .. I'm not very good in regular expressions indeed.
EDIT: And I'm sorry ... [:space:] is not the solution, because the script should work in FreeBSD as well and it uses "truss" instead of "strace" and there's no space after ",
Last edited by Yogesh Sawant; 03-24-2010 at 11:02 PM..
Reason: added code tags
i was attempting to extract a directory path that was passed from a parameter with this code
vdir=`dirname $p1`
echo current directory $vdir
it does not work when the parameter passed has wild card on it.
for example
$ sh sample1.sh "/sbin/log/c*.log"
dirname: extra operand... (2 Replies)
Hi everyone,
I have different folders which looks like this:
/mnt/ecrm/master/ecrm/templates/brochure/de_DE/zeitlos.ott
/mnt/ecrm/master/ecrm/templates/mail/en_US/default.html
/templates/header_and_footer/en_US/default.txt
I want to get the bold text only in a variable. I already have a... (3 Replies)
Hi all,
i've a string
$DIR=/u/user/NDE/TEST_LOGS/20110622_000005_TEST_11_HD_120/HD/TEST_11_HD_120/hd-12
i need to extract string from 2011.... i.e i need it as 20110622_000005_TEST_11_HD_120 as matched string, and in turn i need to split values 20110622_000005_TEST_11_HD_120 into two.... (6 Replies)
hello,
i have a configuration file app.conf under /tmp, containing values like :
param1=/data/something
param2=/data/somethingelse
i have a bash script that has to list the files under the path that corresponds to param2 :
#!/bin/bash
dir=$(cat tmp/app.conf | grep param2 | sed ... (6 Replies)
Hi,
Could anyone help me in writing a single line code by either using (sed, awk, perl or whatever) to extract a specific path from the PATH environment variable?
for eg: suppose the PATH is being set as follows
PATH=/usr/bin/:/usr/local/bin:/bin:/usr/sbin:/usr/bin/java:/usr/bin/perl3.4
... (2 Replies)
Hi,
I have a environmental variables,
ORACLE_HOME=/u01/oracle/ORCL/db/tech/10.2.0
ORACLE_SID=ORCL
Now I need to create a variable and need to extract some part from ORACLE_HOME. I need to get the path from ORACLE_HOME till ORACLE_SID as /u01/oracle/ORCL. I may need to check also... (6 Replies)
Hi all,
I know this has been covered a lot, I have been searching and reading for hours on the subject, however so far I have been unsuccessful at accomplishing the goal using sed.
I know this can be done with parameter expansion (Thanks cfajohnson for a great explanation of parameter... (5 Replies)
Im trying to extract a directory from a path entered by the user
Lets say the path is
path=/home/bliss/files/myfile.txt
i wanna extract "/home/bliss/files" from $path ... how can i do this? (4 Replies)
I need to extract a file,which contains the path to a new path.
sample tar file
tar -tfv class.tar | grep client
-rw------- 0/1 99 Jan 22 12:46 2004 /usr/openv/netbackup/db/class/mariner/clients
-rw------- 0/1 102 Sep 25 11:33 2007... (1 Reply)