Sponsored Content
Top Forums Shell Programming and Scripting sed - replacement file path with variable - Escaping / character Post 302909214 by Don Cragun on Tuesday 15th of July 2014 01:34:37 PM
Old 07-15-2014
Assuming that I understand correctly what you're trying to do (i.e., delete the directory portion of the pathname in the first double quoted string on the 4th line of a file), this seems to be an easy way to do it:
Code:
sed  -i '4s/"[^"]*\\/"/' "$FILE"

This will not, however, work correctly if there is no directory given in that first double quoted string.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Escaping the * character in ksh.

Hi All, In ksh script i'm trying to assign "sqlstmt1" varaible value, update VAREntryTb set VAR10num = VAR1num * Mltplr where BusD = '$val1' and RunI = 1"` Hence i wrote below statement, the issue with this is shell is expanding "*" character adn thus subistuting it with the content of my... (6 Replies)
Discussion started by: arvindcgi
6 Replies

2. Shell Programming and Scripting

Sed-Special character replacement

Hi I want to replace ./testsed.ksh with testsed.ksh ./ is to be removed scriptnm=`sed -e 's/\.///' $0 does not work Please help (3 Replies)
Discussion started by: usshell
3 Replies

3. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

4. Shell Programming and Scripting

Escaping specific character in awk

Hello there, I have a bit of dirty delimited file, I mentioned dirty because, the delimiter can also appear in wrong positions. However, one uniqueness of this file is whenever the delimiter appear inside the double quote, then do not consider as delimiter, if it appear outside double then... (8 Replies)
Discussion started by: brainyoung
8 Replies

5. Shell Programming and Scripting

setting variable value to dynamic sed match - escaping hell

Hello All, I'm trying to write a script that will perform a dynamic match (of a dynamic variable) and set a variable to have the resulting (match) value. The idea is that the environment variable to check ($1) and the regular expression to use ($2) are given as parameters. For example,... (5 Replies)
Discussion started by: aedgar
5 Replies

6. Shell Programming and Scripting

Path a variable to sed that includes a path

Hi I'm trying to select text between two lines, I'm using sed to to this, but I need to pass variables to it. For example start="BEGIN /home/mavkoup/data" end="END" sed -n -e '/${start}/,/${end}/g' doesn't work. I've tried double quotes as well. I think there's a problem with the / in the... (4 Replies)
Discussion started by: mavkoup
4 Replies

7. Shell Programming and Scripting

escaping path

Hi I use : path=/var/www/admin echo "$path" | sed -e 's/\//\\\//g' this return \/var\/www\/admin and is ok. but path2=`echo "$path" | sed -e 's/\//\\\//g'` echo $path2 return an error: sed: -e expression #1, char 9: unknown option to `s' Can anyone help me? Thanks (3 Replies)
Discussion started by: georgian
3 Replies

8. Shell Programming and Scripting

sed replacement in file when line is in a variable

Hi, I have a file where I want to replace the 15th field separated by comma, only on specific lines matching lots of different conditions. I have managed to read the file line by line, within the loop my line is held in a variable called $line I assume this will be using sed (maybe... (5 Replies)
Discussion started by: jpt123
5 Replies

9. Shell Programming and Scripting

Sed:- Supported variable replacement after string match?

Hi All, I am trying to replace the variable in the file after the particular match string. It is being replaced if i hardcode the value and with use of "&" with sed. sed -e "s/URL./& http:\\localhost:7223/g" But when am trying to pass the variable it is failing. I tried multiple... (9 Replies)
Discussion started by: sharsour
9 Replies

10. UNIX for Beginners Questions & Answers

How to use sed to insert character in the beginning of file path?

I need to manipulate one Database file on Solaris 11 in which contains more than 5000 lines of data file path like this: '/data1/oradata/DBNAME/system01.dbf', '/data7/oradata/DBNAME/undotbs1_01.dbf', '/data1/oradata/DBNAME/sysaux01.dbf', '/data28/oradata/DBNAME/userdata01.dbf', ... (6 Replies)
Discussion started by: duke0001
6 Replies
PPI::Token::Quote::Double(3)				User Contributed Perl Documentation			      PPI::Token::Quote::Double(3)

NAME
PPI::Token::Quote::Double - A standard "double quote" token INHERITANCE
PPI::Token::Quote::Double isa PPI::Token::Quote isa PPI::Token isa PPI::Element DESCRIPTION
A "PPI::Token::Quote::Double" object represents a double-quoted interpolating string. The string is treated as a single entity, PPI will not try to understand what is in the string during the parsing process. METHODS
There are several methods available for "PPI::Token::Quote::Double", beyond those provided by the parent PPI::Token::Quote, PPI::Token and PPI::Element classes. Got any ideas for methods? Submit a report to rt.cpan.org! interpolations The interpolations method checks to see if the double quote actually contains any interpolated variables. Returns true if the string contains interpolations, or false if not. simplify For various reasons, some people find themselves compelled to have their code in the simplest form possible. The "simply" method will turn a simple double-quoted string into the equivalent single-quoted string. If the double can be simplified, it will be modified in place and returned as a convenience, or returns false if the string cannot be simplified. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.18.2 2011-02-25 PPI::Token::Quote::Double(3)
All times are GMT -4. The time now is 12:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy