Sponsored Content
Top Forums Shell Programming and Scripting Help with sed backreference please Post 302897187 by Herrick on Friday 11th of April 2014 01:50:05 PM
Old 04-11-2014
Help with sed backreference please

Hi,

I'm using /bin/sh

I would appreciate if someone could help me with SED syntax for a "simple" line.

Here is where I Got to:


I have these strings that are returned by my(Examples) (naturally "FullPath" is always changing don't hardcode this lol)
FullPath/AAA.framework
FullPath/BBB.framework
FullPath/CCC.framework
FullPath/DDD.framework

That I want to convert to
FullPath/AAA.framework/Versions/5/AAA
FullPath/BBB.framework/Versions/5/BBB
FullPath/CCC.framework/Versions/5/CCC
FullPath/DDD.framework/Versions/5/DDD

So basically I want to seach for "anything" after a slash up to the dot and "extract it" to copy it to the end of the string.

I'm banging my head but here is where I got to (feel like I'm near a solution)
Code:
MyFindCommand | sed -e "s/\(.*Framework\)/\1\/Versions\\/5\//"`

Any help would be really appreciated

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

egrep vs. sed backreference

My egrep outputs this: $ cat html.out|sed -n '/bluetext/s/&nbsp;/ /gp'|egrep '{5}' <span class="bluetext"><b> Lexington Park, MD 20653</b></span> But my backreference \1 is empty. I dont understand why. Can someone clarify? $ cat html.out|sed -n '/bluetext/s/&nbsp;/ /gp'|sed -n... (1 Reply)
Discussion started by: r0sc0
1 Replies

2. Shell Programming and Scripting

Issue with a sed one liner variant - sed 's/ ; /|/g' $TMP1 > $TMP

Execution of the following segment is giving the error - Script extract:- OUT=$DATADIR/sol_rsult_orphn.bcp TMP1=${OUT}_tmp1 TMP=${OUT}_tmp ( isql -w 400 $dbConnect_OPR <<EOF select convert(char(10), s.lead_id) +'|' + s.pho_loc_type, ";", s.sol_rsult_cmnt, ";", +'|'+ s.del_ind... (3 Replies)
Discussion started by: kzmatam
3 Replies

3. Shell Programming and Scripting

sed over writes my original file (using sed to remove leading spaces)

Hello and thx for reading this I'm using sed to remove only the leading spaces in a file bash-280R# cat foofile some text some text some text some text some text bash-280R# bash-280R# sed 's/^ *//' foofile > foofile.use bash-280R# cat foofile.use some text some text some text... (6 Replies)
Discussion started by: laser
6 Replies

4. UNIX for Dummies Questions & Answers

Help | Unix | grep | regular expression | backreference | Syntax/Logic

Hello, I'm working on learning regular expressions and what I can do with them. I'm using unix to and its programs to experiment and learn what my limitations are with them. I'm working on duplicating the regular expression: ^(.*)(\r?\n\1)+$ This is supposed to delete duplicate lines... (2 Replies)
Discussion started by: MykC
2 Replies

5. Shell Programming and Scripting

sed regex backreference replacement

Hello, I want to rename multiple files and catch some points about backreference within sed and regex. Here is a part of my file list. Input: S92A.fa S92B.fa ... S96Z.fa S921.fa S922.fa ... S997.fa Note: The file names are not necessarily continuous from A~Z or 921 ~ 997, as some of the... (3 Replies)
Discussion started by: yifangt
3 Replies

6. Shell Programming and Scripting

Printf with backreference in ruby

Hello everybody, May you help with this, I don't know what is wrong. I want trying to print the first 4 characters as decimal and remove the "k's" from the next 7 characters. I'm trying with gsub and backrefence as shown below trying to remove the "k's" and then trying to assign to "x" the... (0 Replies)
Discussion started by: Ophiuchus
0 Replies

7. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

8. Shell Programming and Scripting

Regex and backreference to replace in binary file

Hello to all, I have this sed script that replaces hex strins within a binary file. As you can see, I want to replace all bytes 4X with 2X (where X could take values 0 to F). sed -e 's/\x40/\x20/g' -e 's/\x41/\x21/g' -e 's/\x42/\x22/g' -e 's/\x43/\x23/g' -e 's/\x44/\x24/g' -e... (7 Replies)
Discussion started by: Ophiuchus
7 Replies

9. Shell Programming and Scripting

I am learning regular expression in sed,Please help me understand the use curly bracket in sed,

I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement, Question : 1 __________ /opt/oracle/work/antony>cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit... (7 Replies)
Discussion started by: Antony Ankrose
7 Replies

10. UNIX for Advanced & Expert Users

Segregate file content using sed backreference

I have some text like EU1BTDAT:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1BTDATEST:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1CLOSEDATES:ASSGNDD filename='$SEQFILES/SUNIA.PJ008202.CARDLIB/DATECARD' EU1DATED:ASSGNDD... (8 Replies)
Discussion started by: gotamp
8 Replies
LINEDISC(9)						   BSD Kernel Developer's Manual					       LINEDISC(9)

NAME
linedisc, ttyldisc_add, ttyldisc_lookup, ttyldisc_remove -- extensible line discipline framework SYNOPSIS
#include <sys/conf.h> int ttyldisc_add(struct linesw *disc, int no); struct linesw * ttyldisc_remove(const char *name); struct linesw * ttyldisc_lookup(const char *name); DESCRIPTION
The NetBSD TTY line discipline framework allows extensibility. Modules that need special line disciplines can add them as convenient and do not need to modify tty_conf.c. Line disciplines are now managed by a string, rather than number. Once the framework has been initialized, a new line discipline can be added by creating and initializing a struct linesw and calling ttyldisc_add(). The following is a brief description of each function in the framework: ttyldisc_add() Register a line discipline. The l_name field of the struct linesw should point to a string which is to be the symbolic name of that line discipline. For compatibility purposes, a line discipline number can be passed in no, but for new dis- ciplines this should be set to -1. ttyldisc_lookup() Look up a line discipline by name. NULL is returned if it can not be found. ttyldisc_remove() Remove a line discipline called name and return a pointer to it. If the discipline cannot be found or removed ttyldisc_remove() will return NULL. SEE ALSO
tty(4) HISTORY
The linedisc functions were added in NetBSD 1.6. AUTHORS
The NetBSD extensible line discipline framework was created by Eduardo Horvath <eeh@NetBSD.org>. BSD
November 1, 2000 BSD
All times are GMT -4. The time now is 05:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy