Sponsored Content
Full Discussion: Regex extracting location
Top Forums Shell Programming and Scripting Regex extracting location Post 302953393 by Chubler_XL on Thursday 27th of August 2015 04:02:13 PM
Old 08-27-2015
Another approach is to get the bit you want to delete into a variable then trim that from line like this:

Code:
$ line=/got/cpp/track/tmp/piy/p_tok.xml
$ del=${line##*/tmp/}
$ echo $del
piy/p_tok.xml
$  echo ${line%/$del}
/got/cpp/track/tmp

or as a 1 liner:

Code:
$ echo ${line%/${line##*/tmp/}}
/got/cpp/track/tmp

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed, grep, awk, regex -- extracting a matched substring from a file/string

Ok, I'm stumped and can't seem to find relevant info. (I'm not even sure, I might have asked something similar before.): I'm trying to use shell scripting/UNIX commands to extract URLs from a fairly large web page, with a view to ultimately wrapping this in PHP with exec() and including the... (2 Replies)
Discussion started by: ropers
2 Replies

2. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies

3. Shell Programming and Scripting

Extracting a regex with awk

I have a regexp that I wish to match against every line of a file using awk. But I do not want to substitute it or select the line. I want to pull the matched text out and put it in a different file, line by line. What is the correct awk usage to *extract* a regexp and put it in another... (11 Replies)
Discussion started by: Enobarbus37
11 Replies

4. Solaris

Extracting file from tar at relative location!!

Hi Gurus, I have a .tar file which required untar to the new location. I list the content with –tvf its listing the files which are inside the tar, when I am extracting he file from tar its working fine, however once I am trying to extract the file at the new location I am unable to do so. I... (11 Replies)
Discussion started by: kumarmani
11 Replies

5. Shell Programming and Scripting

Put one string from one location to another location in a file

Hi Everyone, I have 1.txt here a b c' funny"yes"; d e The finally output is: here a b c d e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies

6. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

7. Shell Programming and Scripting

Help on Moving files from one location to another location

Hi, I am new to unix and shell scripting. Please help me in resolving the below issue. In my shell script I have a variable which stores the different files with the path. Now I need to move all the files one by one to another location. ---- 1.... (4 Replies)
Discussion started by: kpagadala
4 Replies

8. Shell Programming and Scripting

File created in a different location instead of desired location on using crontab

Hi, I am logging to a linux server through a user "user1" in /home directory. There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory. When the script is added to crontab, on... (1 Reply)
Discussion started by: archana.n
1 Replies

9. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

10. Shell Programming and Scripting

Help with copying the list of files from one location to other location

A) I would like to achive following actions using shell script. can someone help me with writing the shell script 1) Go to some dir ( say /xyz/logs ) and then perform find operation in this dir and list of subdir using find . -name "*" -print | xargs grep -li 1367A49001CP0162 >... (1 Reply)
Discussion started by: GG2
1 Replies
CPP(1)							      General Commands Manual							    CPP(1)

NAME
cpp - C language preprocessor SYNOPSIS
cpp [ option ... ] [ ifile [ ofile ] ] DESCRIPTION
Cpp interprets ANSI C preprocessor directives and does macro substitution. The input ifile and output ofile default to standard input and standard output respectively. The options are: -Dname -Dname=def -Idir Same as in 2c(1). -M Generate no output except a list of include files in a form suitable for specifying dependencies to mk(1). Use twice to list files in angle brackets. -N Turn off default include directories. All must be specified with -I. Without this option, /$objtype/include and /sys/include are used as the last two searched directories for include directives, where $objtype is read from the environment. -V Print extra debugging information. -+ Understand C++ comments. The output file contains processed text sprinkled with lines that show the original input line numbering: #line linenumber "ifile" The input language is as described in the ANSI C standard. The C compilers do not use cpp; they contain their own simple but adequate pre- processor, so cpp is usually superfluous. FILES
/sys/include directory for machine-independent include files /$objtype/include directory for machine-dependent include files SOURCE
/sys/src/cmd/cpp SEE ALSO
2c(1) CPP(1)
All times are GMT -4. The time now is 01:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy