Sponsored Content
Top Forums UNIX for Advanced & Expert Users How do i use vi to substitute an expression that is part of a path? Post 302431703 by durden_tyler on Wednesday 23rd of June 2010 02:07:07 PM
Old 06-23-2010
Code:
$
$ X="/home/user1/bin/"
$
$ echo $X
/home/user1/bin/
$
$ echo $X | sed -e 's/\/home\/user1/\/root/' -e 's/\/$//'
/root/bin
$
$

tyler_durden

---------- Post updated 06-23-10 at 02:07 PM ---------- Previous update was 06-22-10 at 03:51 PM ----------

Quote:
Originally Posted by c00lsnoopy
Let say I have /home/user1/bin/ and i want it to be /root/bin
I tried :
Code:
s/\/home\/user1/user2/

but it can't find the pattern user1.
I tried:
Code:
s/*\/home\/user1*/user2/

as well same result
...
Sorry, I did not notice that you want to do this in vi editor.

Place your cursor on the line that has the string "/home/user1/bin/" and hit ":" for the editor prompt. Then type the following and press "Enter" -

Code:
s/\/home\/user1\/\(.*\)\//\/root\/\1/

I don't have vi, but this works in vim.

HTH,
tyler_durden
This User Gave Thanks to durden_tyler For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting the path part of an argument

Seems I'm inundating this forum with questions, but anyway: I am writing a script that should accept one and only one argument when called. That argument should designate a file, either with path/filename or just filename. Now to the difficult bit: I want to figure out a way to store... (9 Replies)
Discussion started by: ropers
9 Replies

2. Shell Programming and Scripting

retrieve part of file path

Hi I am trying to use sed to retrieve part of my html file's path. I am having a hard time getting what I want. Could someone give me some help? I want to retrieve the section after html and before the file name For example if I have the following, ... (3 Replies)
Discussion started by: tiger66
3 Replies

3. Shell Programming and Scripting

regex to select last part of a path

Hi all, I am learning the use of regular expression and I would like to know which regex can be used to select only the last part of a directory path name. Something like: /dir1/dir2/dir2 and I want to select the last /dir2 where dir2 can be any kind of string. Thanks a lot for your help.... (7 Replies)
Discussion started by: elric
7 Replies

4. Shell Programming and Scripting

taking a part of string from a given path

Hi I have two path as follows system/console/bin/code/sample/testfile.txt system/console/bin/database/files/new/dbfile.txt I need the output as code/sample in first case database/files/new in second case That is I am omitting system/console/bin and the filename(s) in both... (2 Replies)
Discussion started by: ssuresh1999
2 Replies

5. Shell Programming and Scripting

AWK script issue for the part regular expression

Hi I am having a file as shown below FILE 1 TXDD00, TXDD01, TXDD02, TXDD03, TXDD04, TXDD05, TXDD06, TXDD07, TXDD08, TXDD09, TXDD10, TXDD11, TXDD12, TXDD13, TXDD14, TXDD15, TXDD16, TXDD17, TXDD18, TXDD19, TXDDCLK, TXDJTAGAMPL0, TXDJTAGAMPL1,... (3 Replies)
Discussion started by: jaita
3 Replies

6. Shell Programming and Scripting

How to substitute a line that matches an expression with another line

I need some help. I have a file (all.txt) whereby I want to substitute using sed/awk all lines that matches an expression with another line with different expression i.e subtitute expression, database_id: filename; WITH database_id: PY; There are many occurrences of the expression... (4 Replies)
Discussion started by: aimsoft
4 Replies

7. Shell Programming and Scripting

Perl command to replace path part of variable

I'm trying to replace path which is part of variable inside script file: FROM: ABC_HOME=$ABC_ROOT/abc/1.0 TO: ABC_HOME=$ABC_ROOT/abc/1.5 I'm using this: perl -pi -e 's\ABC_HOME=$ABC_ROOT/abc/1.0\ABC_HOME=$ABC_ROOT/abc/1.5\g' /apps/scripts/test.sh This command is not working because... (2 Replies)
Discussion started by: djanu
2 Replies

8. Shell Programming and Scripting

Grep regular expression to get part of a line

Hi I just started on GNU Grep with regex and am finding it very challenging and need to ask for help already... here is the problem, I have a page (MYFILE) which consists of the following.... <div> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden"... (2 Replies)
Discussion started by: noobie74645
2 Replies

9. Shell Programming and Scripting

String variable as part of expression in find command

Hi, I am new in scripting, and I am currently working on a script that will look for other files in a certain directory and exclude some file type. this works fine:Find_File2Exclude=`find ${paths} -maxdepth 1 -type f \( ! -iname '*.out' ! -iname '*.auc' ! -iname '*.cps' ! -iname '*.log' ! -iname... (4 Replies)
Discussion started by: kedd05
4 Replies

10. UNIX for Advanced & Expert Users

A way to print only part of directory path

Hi, So I struggled to find a solution to the following problem: I want to make sed print only part of multiple different paths. So lets say we have /path/path1/path2/logs/bla/blabla /path/path1/path2/path3/logs/yadda/yadda/yadda Can someone suggest a way to make sed or other... (5 Replies)
Discussion started by: dampio
5 Replies
dspam_merge(1)							       DSPAM							    dspam_merge(1)

NAME
dspam_merge - merge several users' metadata into a composite SYNOPSIS
dspam_merge [--profile=PROFILE] user1 user2 ... userN -o username DESCRIPTION
dspam_merge merges several users' metadata into a single user's dictionary. This tool is designed to create global users and seeded data. The hit sounds for each token and per-user totals are added together to produce a single composite dataset. After creating a composite user, dspam_clean should be run with the -p option to clean up extraneous data. NOTE : Merges may take a considerable amount of time. This could potentially increase the load on the server or even slow down the delivery of email. A merge should only be performed when the system is fairly acquiesce. OPTIONS
--profile=PROFILE Specify a storage profile from dspam.conf. The storage profile selected will be used for all database connectivity. See dspam.conf for more information. user1 user2 ... userN A list of users to merge together. -o username The target user which will be created (if necessary). This user will contain the composite generated by the merge. EXAMPLES
dspam_merge dick jane spot -o ralph Merges the metadata dictionaries of dick, jane, and spot into a single composite under the user ralph EXIT VALUE
0 Operation was successful. other Operation resulted in an error. COPYRIGHT
Copyright (C) 2002-2011 DSPAM Project All rights reserved. For more information, see http://dspam.sourceforge.net. SEE ALSO
dspam(1), dspam_admin(1), dspam_clean(1), dspam_crc(1), dspam_dump(1), dspam_logrotate(1), dspam_stats(1), dspam_train(1) DSPAM
Apr 17, 2010 dspam_merge(1)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy