Sponsored Content
Full Discussion: File search variables
Top Forums Shell Programming and Scripting File search variables Post 302150785 by porter on Wednesday 12th of December 2007 04:39:49 PM
Old 12-12-2007
How will the code get the list of files to search?

Could you not just start at today and work backwards?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ksh script - Design ? - Search file and set variables

Hi - I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem: Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
Discussion started by: littlefrog
9 Replies

2. Shell Programming and Scripting

search and replace using awk with variables

Hi, I have been trying to use awk with variables that needs to search for a pattern and replace it with another pattern, the patterns are supplied in a variable. I have tried several different ways without success and hope that someone can help me. Here are the details echo $UPC 07007457809... (2 Replies)
Discussion started by: jerardfjay
2 Replies

3. HP-UX

Search environment variables for paths

Hi, I am using the HP machine at the moment and by default I have been setup with the kron shell i.e. my home profile is .kshrc I would like to access a program anywhere on the system so I have added a path and created an environment variable like this: export myvarpath=/a/abc/def/ghij... (3 Replies)
Discussion started by: cyberfrog
3 Replies

4. Shell Programming and Scripting

Search between 2 variables

Hi Guys... can you tell me how to search between 2 variables ?... Im looking for a script that will move the data between varying words to separate files. I dont have my data on which I need to work right now... but it looks something like this.. start name1 data(a) data(b) stop name1 ... (6 Replies)
Discussion started by: R!C
6 Replies

5. UNIX for Advanced & Expert Users

use of variables in awk to search for pattern from a file

Hi, I need to extract all the content between two strings stored in two variables "startstring" and "endstring" startstring=hello enstring=world #notworking awk '/$startstring/, $NF ~ /$endstring/ ' file > file2 The above code is not working with variables. It works when actual string... (2 Replies)
Discussion started by: jeanjkj
2 Replies

6. Shell Programming and Scripting

awk - ignore metacharacters, search shell variables

Can I use awk to search for a string, passed from the shell, that might include metacharacters? File1 entries: Bob Marley Jammin (Bonus Track).mp3 File2 entries: Bob Marley Jammin (Bonus Track).mp3 32000 /Music/Bob Marley/ Jammin (Bonus Track).mp3 So far, I have this; $ sed -e... (9 Replies)
Discussion started by: DSommers
9 Replies

7. Shell Programming and Scripting

awk search/replace specific field, using variables for regexp & subsitution then overwrite file

Hello, I'm trying the solve the following problem. I have a file which I intend to use as a csv called master.csv The columns are separated by commas. I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies

8. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

9. Shell Programming and Scripting

Retrieving the relevant search from search file in the main file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search... (7 Replies)
Discussion started by: csim_mohan
7 Replies

10. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies
File::Basename(3pm)					 Perl Programmers Reference Guide				       File::Basename(3pm)

NAME
File::Basename - Parse file paths into directory, filename and suffix. SYNOPSIS
use File::Basename; ($name,$path,$suffix) = fileparse($fullname,@suffixlist); $name = fileparse($fullname,@suffixlist); $basename = basename($fullname,@suffixlist); $dirname = dirname($fullname); DESCRIPTION
These routines allow you to parse file paths into their directory, filename and suffix. NOTE: "dirname()" and "basename()" emulate the behaviours, and quirks, of the shell and C functions of the same name. See each function's documentation for details. If your concern is just parsing paths it is safer to use File::Spec's "splitpath()" and "splitdir()" methods. It is guaranteed that # Where $path_separator is / for Unix, for Windows, etc... dirname($path) . $path_separator . basename($path); is equivalent to the original path for all systems but VMS. "fileparse" my($filename, $directories, $suffix) = fileparse($path); my($filename, $directories, $suffix) = fileparse($path, @suffixes); my $filename = fileparse($path, @suffixes); The "fileparse()" routine divides a file path into its $directories, $filename and (optionally) the filename $suffix. $directories contains everything up to and including the last directory separator in the $path including the volume (if applicable). The remainder of the $path is the $filename. # On Unix returns ("baz", "/foo/bar/", "") fileparse("/foo/bar/baz"); # On Windows returns ("baz", 'C:fooar', "") fileparse('C:fooaraz'); # On Unix returns ("", "/foo/bar/baz/", "") fileparse("/foo/bar/baz/"); If @suffixes are given each element is a pattern (either a string or a "qr//") matched against the end of the $filename. The matching portion is removed and becomes the $suffix. # On Unix returns ("baz", "/foo/bar/", ".txt") fileparse("/foo/bar/baz.txt", qr/.[^.]*/); If type is non-Unix (see "fileparse_set_fstype") then the pattern matching for suffix removal is performed case-insensitively, since those systems are not case-sensitive when opening existing files. You are guaranteed that "$directories . $filename . $suffix" will denote the same location as the original $path. "basename" my $filename = basename($path); my $filename = basename($path, @suffixes); This function is provided for compatibility with the Unix shell command basename(1). It does NOT always return the file name portion of a path as you might expect. To be safe, if you want the file name portion of a path use "fileparse()". "basename()" returns the last level of a filepath even if the last level is clearly directory. In effect, it is acting like "pop()" for paths. This differs from "fileparse()"'s behaviour. # Both return "bar" basename("/foo/bar"); basename("/foo/bar/"); @suffixes work as in "fileparse()" except all regex metacharacters are quoted. # These two function calls are equivalent. my $filename = basename("/foo/bar/baz.txt", ".txt"); my $filename = fileparse("/foo/bar/baz.txt", qr/Q.txtE/); Also note that in order to be compatible with the shell command, "basename()" does not strip off a suffix if it is identical to the remaining characters in the filename. "dirname" This function is provided for compatibility with the Unix shell command dirname(1) and has inherited some of its quirks. In spite of its name it does NOT always return the directory name as you might expect. To be safe, if you want the directory name of a path use "fileparse()". Only on VMS (where there is no ambiguity between the file and directory portions of a path) and AmigaOS (possibly due to an implementation quirk in this module) does "dirname()" work like "fileparse($path)", returning just the $directories. # On VMS and AmigaOS my $directories = dirname($path); When using Unix or MSDOS syntax this emulates the dirname(1) shell function which is subtly different from how "fileparse()" works. It returns all but the last level of a file path even if the last level is clearly a directory. In effect, it is not returning the directory portion but simply the path one level up acting like "chop()" for file paths. Also unlike "fileparse()", "dirname()" does not include a trailing slash on its returned path. # returns /foo/bar. fileparse() would return /foo/bar/ dirname("/foo/bar/baz"); # also returns /foo/bar despite the fact that baz is clearly a # directory. fileparse() would return /foo/bar/baz/ dirname("/foo/bar/baz/"); # returns '.'. fileparse() would return 'foo/' dirname("foo/"); Under VMS, if there is no directory information in the $path, then the current default device and directory is used. "fileparse_set_fstype" my $type = fileparse_set_fstype(); my $previous_type = fileparse_set_fstype($type); Normally File::Basename will assume a file path type native to your current operating system (ie. /foo/bar style on Unix, fooar on Windows, etc...). With this function you can override that assumption. Valid $types are "MacOS", "VMS", "AmigaOS", "OS2", "RISCOS", "MSWin32", "DOS" (also "MSDOS" for backwards bug compatibility), "Epoc" and "Unix" (all case-insensitive). If an unrecognized $type is given "Unix" will be assumed. If you've selected VMS syntax, and the file specification you pass to one of these routines contains a "/", they assume you are using Unix emulation and apply the Unix syntax rules instead, for that function call only. SEE ALSO
dirname(1), basename(1), File::Spec perl v5.16.3 2013-03-04 File::Basename(3pm)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy