Sponsored Content
Top Forums Shell Programming and Scripting Pattern match and replace indirect directory reference using sed Post 302962244 by andyatit on Thursday 10th of December 2015 09:16:58 AM
Old 12-10-2015
Pattern match and replace indirect directory reference using sed

Hi,

I need a ksh script to replace indirect directory references in an .ini file with a env variable using sed or awk.

The .ini file is for example as such:

Code:
A=..
B=../
C=../..
D=../../
E=../bin
F=../../bin
G=../../bin/xml
H=../../bin/xml/

Need to replace an instance of .. or ../.. with %HOME%

so

Code:
A=%HOME%
B=%HOME%/
C=%HOME%
D=%HOME%/
E=%HOME%/bin
F=%HOME%/bin
G=%HOME%/bin/xml
H=%HOME%/bin/xml/


Last edited by andyatit; 12-10-2015 at 10:20 AM.. Reason: Add shell
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - Replace Line which contains the Pattern match with a new line

I need to replace the line containing "STAGE_DB" with the line "STAGE_DB $DB # database that contains the table being loaded ($workingDB)" Here $DB is passed during the runtime. How can I do this? Thanks, Kousikan (2 Replies)
Discussion started by: kousikan
2 Replies

2. Shell Programming and Scripting

Match pattern and replace

Hi All, I am new to unix shell scripting, I need your help guys in coming up with some thing for the following scenario: file1 ABC_BASE ${base} ABC_ACC ${acc} ABC_TEST ${test} 01-01-2006 ${from_dt} 01-15-2006 ${to_dt} file 2 I have an file2.sql file which contains: ####This... (4 Replies)
Discussion started by: sol_nov
4 Replies

3. Shell Programming and Scripting

Match a pattern starting with sub-pattern using sed

Hi all, I've been experiencing a difficulty trying to match a number and write it to a new file. My input file is: input.txt It contains the lines: 103P 123587.256971 3.21472112 3.1517423 1.05897234566427 58.2146258 12.35478 25.3612489 What would be the sed command to... (17 Replies)
Discussion started by: Biederman
17 Replies

4. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies

5. Shell Programming and Scripting

Help with Pattern match and replace

I have a file containing a multiple lines of the format sddfdsf_gaf/ywrtrtwrt_gaf ghfghfgh_ert/xcvxcvcv_ert werwerwwerw_adf/jkhjkhjkjhkjhk_adf I am interested in only the first 3 letters following the "_" character and make those 3 letters uppercase after extraction. So would like to convert... (5 Replies)
Discussion started by: inditopgun
5 Replies

6. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

7. Shell Programming and Scripting

sed : match one pattern then the next consecutive second pattern not working

Ive used this snippet of code on a solaris box thousands of times. But it isnt working on the new linux box sed -n '/interface LoopBack0/{N;/ ip address /p;}' *.conf its driving me nuts !! Is there something Im missing ? (7 Replies)
Discussion started by: popeye
7 Replies

8. Shell Programming and Scripting

sed and awk usage to grep a pattern 1 and with reference to this grep a pattern 2 and pattern 3

Hi , I have a file where i have modifed certain things compared to original file . The difference of the original file and modified file is as follows. # diff mir_lex.c.modified mir_lex.c.orig 3209c3209 < if(yy_current_buffer -> yy_is_our_buffer == 0) { --- >... (5 Replies)
Discussion started by: breezevinay
5 Replies

9. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

10. Shell Programming and Scripting

If pattern match, replace it with #

This command is not working for me. awk '{if ($1 == server) {$1 = #server} }' /etc/ntp.conf # grep server /etc/ntp.conf # Use public servers from the pool.ntp.org project. server 0.rhel.pool.ntp.org iburst server 1.rhel.pool.ntp.org iburst server 2.rhel.pool.ntp.org iburst server... (5 Replies)
Discussion started by: kenshinhimura
5 Replies
IVMAN(8)						      System Manager's Manual							  IVMAN(8)

NAME
ivman - volume manager SYNOPSIS
ivman [ -sd ] [ --nofork ] [ -c <directory> ] DESCRIPTION
Ivman, or Ikke's Volume Manager, is a daemon to handle the mounting of media as they are inserted/attached to the system. It can also be used to execute arbitrary commands when a device with certain properties is added to the system (Windows autoplay style functionality), and to execute arbitrary commands when device properties change. Ivman uses HAL to monitor the state of your system's hardware. OPTIONS
-s or --system Start Ivman in system-wide mode. This is the default if running Ivman as root. When this option is specified, Ivman reads from the system-wide configuration directory ( usually /etc/ivman/ ); if this option is not specified, Ivman reads from ${HOME}/.ivman/ instead. Either of these locations may be overridden with the -c option. Other behaviour may differ slightly when running in sys- tem-wide mode. Don't use this option unless you know you need it. --nofork Force Ivman not to daemonize, regardless of settings in IvmConfigBase.xml. Useful for capturing debugging output. -d or --debug Force Ivman to give debugging output, regardless of settings in IvmConfigBase.xml. -c <directory> or --confdir <directory> Force Ivman to load configuration files from the specified directory. DETAILS
Ivman is a flexible device manager, allowing users to run arbitrary commands when devices are added/removed, when device properties change, and when devices emit conditions. For automount purposes, Ivman should be run once from a system-wide init script and once per user session (e.g., create a link to /usr/bin/ivman in ~/.kde/Autostart or put an entry for /usr/bin/ivman in gnome-session-manager). When a device is attached, Ivman will call pmount or mount to mount the device. If pmount is used, it will mount the device readable and writeable only for the current user; if no per-user instance of Ivman is running, the device will be mounted read/write for everyone in the same group as is required to use the pmount command, and read-only for everyone else. If regular mount is used, then an fstab entry must exist in /etc/fstab for the device to be mounted, and the settings given in that fstab entry will be used for the mount. Ivman is supplied with sensible default configuration files for volume management, but autoplay functionality has no default actions; you will need to edit ${HOME}/.ivman/IvmConfigActions.xml(5) or /etc/ivman/IvmConfigActions.xml(5) to specify some programs to execute. The syntax of this file and the other Ivman configuration files are specified in their own manpages. FILES
/etc/ivman/IvmConfigActions.xml actions to perform when media is inserted /etc/ivman/IvmConfigBase.xml options affecting the running of Ivman /etc/ivman/IvmConfigConditions.xml actions to perform when devices emit conditions /etc/ivman/IvmConfigProperties.xml actions to perform when device properties change SEE ALSO
IvmConfigActions.xml(5), IvmConfigBase.xml(5), IvmConfigConditions.xml(5), IvmConfigProperties.xml(5) BUGS
Hopefully, none :-) But there could be some still lurking. If you encounter a bug, please forward details to rohan.pm@gmail.com or add it to the bug tracker at the project's Sourceforge page, http://sourceforge.net/projects/ivman 9 December 2005 IVMAN(8)
All times are GMT -4. The time now is 07:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy