Sponsored Content
Full Discussion: sed - issue in replacing >
Top Forums Shell Programming and Scripting sed - issue in replacing > Post 302937835 by Don Cragun on Monday 9th of March 2015 10:36:17 PM
Old 03-09-2015
This is still VERY confusing. If we look at message #19 in this thread as the current specification of what you are trying to do, we still can't tell what the parameter is in your parameterized directory nor how that parameter is set (both of which are needed to complete your project). What is the name of the parameter being used in your script that contains the text that is to replace the directory value in Output file directory attribute values? How are you setting that parameter in your shell?

What operating system are you using? Windows uses \ as the component separator in a pathname. UNIX and UNIX-like systems use / as the component separator in a pathname. As noted above:
  1. your samples seem to use both. Are the backslashes in your sample input:
  2. mistakes (that were intended to be slashes),
  3. literal characters in the names of files (including directories) on your system, or
  4. does your system use both forward slash and backslash as component separators in pathnames?

What shell are you using? To complete your project, quoting and escaping are very important, and quoting and escaping vary greatly between UNIX and UNIX-like system shells and Windows shells.

The sample input file in post #19 contains 22 lines. The sample output file there consists of 44 lines (22 in CODE tags and 22 not in CODE tags). Please clarify what the real output is supposed to be! (I thought maybe the desired output was duplicated, but that is not the case in post #19.) Please be certain that the slash and backslash characters in your post are correct!
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing in SED

I want to change the false in Node 1 to true. How do I do that? <Node1> <Usage>false</Usage> <Url>ABC</Url> </Node1> <Node2> <Usage>false</Usage> <Url>DEF<Url> </Node2> (8 Replies)
Discussion started by: superprogrammer
8 Replies

2. Shell Programming and Scripting

replacing using sed

its again sed question. i have line - sed "s/$old/$new/g" "$f" > $TFILE && mv $TFILE "$f" working well if old="myoldfile" new="mynewfile" but if i want old="/home/shailesh/1test/" new="/home/shailesh/workspace/" it gives error like sed: -e expression #1, char 9: unknown option to... (2 Replies)
Discussion started by: shailesh_arya
2 Replies

3. Shell Programming and Scripting

SED: replacing

Hello, I was looking around, but could not find the answer, so I hope you ppl can help me. I want simply to replace text.:rolleyes: I found out SED would be good for this task.:b: So I tried: :confused: 1.) find text in a line and replace this particular line: for finding... (3 Replies)
Discussion started by: unknown7
3 Replies

4. Shell Programming and Scripting

replacing ' with '' using sed

Hi, I have a text file and I would like to replace all occurrences of single quote ' with two consecutive single quotes '' . I have tried sed s/\'/\'\'/ < Folder/outputFile.txt > Folder/otherFile.txt but this replaces only the first occurrence of ' with ''. I want it to replace all the single... (7 Replies)
Discussion started by: DushyantG
7 Replies

5. Shell Programming and Scripting

sed inside sed for replacing string

My need is : Want to change docBase="/something/something/something" to docBase="/only/this/path/for/all/files" I have some (about 250 files)xml files. In FileOne it contains <Context path="/PPP" displayName="PPP" docBase="/home/me/documents" reloadable="true" crossContext="true">... (1 Reply)
Discussion started by: linuxadmin
1 Replies

6. Shell Programming and Scripting

Need help with SED for replacing an IP

I need some advice to replace 10.183.x.x with 10.174.17.55 in a file containing multiple 10.183.x.x. Any help would be highly appreciated. (1 Reply)
Discussion started by: sags007_99
1 Replies

7. Shell Programming and Scripting

replacing by sed

hi my input file has got >,,,, or >, or >,,,,,, there are independent number of commas after >.... i want the o/p as > only that is just to remove "," after">" another is: i want to replace the last line of the file and to replace it by "hello"...how to do?... any nice script plz help (2 Replies)
Discussion started by: Indra2011
2 Replies

8. Shell Programming and Scripting

Replacing using sed

hi Guys, I have a rar file which consists of 10 files. each file has a space in its file name. how can i replace all spaces with _ i can replace them using sed but the thing is i need to replace using a script and not command. can anyone help me out??:confused: (2 Replies)
Discussion started by: rajeshb6
2 Replies

9. Shell Programming and Scripting

sed not replacing

Data not replacing using sed,please check below. Replace_value=$$dbconn_target Search_value=$$dbcon_source   sed -e s/\${Search_value}/\${Replace_value}/g intrepid_sps_val.parm (2 Replies)
Discussion started by: katakamvivek
2 Replies

10. Shell Programming and Scripting

Not replacing using sed

Hi all, I am trying to change the below word. but the changes is not reflecting in the new file sed -n 's/apple/orange/' filename ---------- Post updated at 12:51 AM ---------- Previous update was at 12:41 AM ---------- I tried this it works perl -pi.bak -e... (9 Replies)
Discussion started by: ramkumar15
9 Replies
basename(3)						     Library Functions Manual						       basename(3)

NAME
basename, dirname, dirname_r - Return the base filename or directory portion of a pathname LIBRARY
Standard C Library (libc) SYNOPSIS
#include <libgen.h> char *basename( char *path); char *dirname( char *path); The following function is supported only for backward compatibility: #include <string.h> int dirname_r( char *path, char *buf, int size); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: basename(), dirname(): XSH4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
The string from which the base pathname or the directory portion is to be extracted. [Tru64 UNIX] Specifies a working buffer to hold the directory name component. [Tru64 UNIX] Specifies the length of buf. DESCRIPTION
The basename() and dirname() functions complement each other. The basename() function reads path and returns a pointer to the final compo- nent of the pathname, deleting any trailing / (slash) characters. If the string consists entirely of the / (slash) character, basename() returns a pointer to the string / (slash). If path is a null pointer or points to an empty string, basename() returns a pointer to the string . (period). [Tru64 UNIX] In applications that are compiled in an environment that excludes the _XOPEN_SOURCE_EXTENDED standard definitions, the base- name() function returns an empty string if the string consists entirely of the / (slash) character. If path is a null pointer, basename() returns a core dump. If path points to an empty string, basename() returns an empty string. The dirname() function reads path and returns a pointer to a new string that is a pathname of the parent directory of that file. Trailing / (slash) characters in the path are not counted as part of the path. If there is no / (slash), if path is a null pointer, or if path points to an empty string, the dirname() function returns a pointer to the string . (period). [Tru64 UNIX] In applications that are compiled in an environment that excludes the _XOPEN_SOURCE_EXTENDED standard definitions, the dirname() function returns a NULL if there is no / (slash), and a core dump if path is a null pointer, or if path points to an empty string. The dirname_r() function is the reentrant version of the dirname() function. It is supported only to maintain backward compatibility with versions of the operating system prior to DIGITAL UNIX Version 4.0. NOTES
The value returned by the basename() and dirname() functions is a pointer to a thread-specific buffer whose contents will be overwritten on subsequent calls from the same thread. [Tru64 UNIX] The basename(), dirname(), and dirname_r() functions belong to a small set of libc functions that are handled differently when compiled in the X/Open UNIX environment. In the X/Open UNIX environment, calls to these functions are internally renamed by prepend- ing _E to the function name. The renaming is done only when there is an incompatible conflict between an existing version of the function and the version that conforms to the X/Open UNIX standard. The renaming strategy supports binary compatibility by allowing applications to compile in the X/Open UNIX environment and also link with site-specific and third-party libraries that use the old versions of the same libc interfaces. However, internal renaming of the calls affects how these calls are identified during debugging sessions. Therefore, when you are debugging a module that includes the basename() and/or dirname() or dirname_r() functions and for which _XOPEN_SOURCE_EXTENDED has been defined, use _Ebasename to refer to the basename() call and _Edirname to refer to the dirname call and _Edirname_r to refer to the dirname_r call. See standards(5) for information on when the _XOPEN_SOURCE_EXTENDED macro is defined. RETURN VALUES
Upon success, the basename() and dirname() functions return the component string. Upon failure, these functions return NULL. If there is no / (slash), the dirname() function returns a . (period). [Tru64 UNIX] In applications that are compiled in an environment that excludes the _XOPEN_SOURCE_EXTENDED standard definitions, the dirname() function returns NULL if there is no / (slash). [Tru64 UNIX] Upon successful completion, the dirname_r() function returns a value of 0 (zero) and places the directory name component in the buffer pointed at by buf. Upon failure (for example, if there is no / (slash)), the dirname_r() function returns -1 and sets errno. ERRORS
If the dirname_r() function fails, errno may be set to the following: The value of the buf parameter is invalid or too small. RELATED INFORMATION
Commands: basename(1) Standards: standards(5) delim off basename(3)
All times are GMT -4. The time now is 08:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy