Sponsored Content
Top Forums Shell Programming and Scripting Find Directory from array of file names with paths Post 302332449 by zaxxon on Thursday 9th of July 2009 06:53:06 AM
Old 07-09-2009
At first: Use CODE-tags when posting code, data or logs for better readability, ty.

No idea what GIS is.

Anyway as a start:

Code:
$> VAR=/Users/myuser/Documents/MemSVC_5493/MemSVC.html
$> cd ${VAR%/*}

If you want to write the new file with the same name as the current directory you can use something like
Code:
$> VAR2=/Users/myuser/Documents/MemSVC_5493
$> echo ${VAR2##*/}
MemSVC_5493

If you want to use the current path as filename, I would change the slashes vs. underscores maybe.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find the length of file names in a directory?

Hi, how can find length of file names in a directory. Examp: I have a directory with name "d1". directory: d1 files: aaa.log bbb.log abcd.log abcdef.log I wold like out put like: file name legnth aaa.log 3 bbb.log 3 abcd.log 4 abcdef.log 5 (5 Replies)
Discussion started by: koti_rama
5 Replies

2. AIX

find for specific content in file in the directory and list only file names

Hi, I am trying to find the content of file using grep and find command and list only the file names but i am getting entire file list of files in the directory find . -exec grep "test" {} \; -ls Can anyone of you correct this (2 Replies)
Discussion started by: madhu_Jagarapu
2 Replies

3. UNIX for Dummies Questions & Answers

Unable to use mimesender to send attachments with spaces in the file names / paths

Hello, I found the mimesender multiple attachment emailing shell script in the FAQ of these forums, and I have been able to use it to send multiple files, but only if they don't have spaces in their file name or path. When I attempt to send a file with spaces in it's name, enclosed... (0 Replies)
Discussion started by: rsmorra
0 Replies

4. Solaris

find home directory paths for all users

How to find al the user's home directories? (2 Replies)
Discussion started by: a2156z
2 Replies

5. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

6. Shell Programming and Scripting

How to store files names from a directory to an array

Hi I want to store the file names into an array. I have written like this but I am getting error. declare -A arr_Filenames ls -l *.log | set -A arr_Filenames $(awk '{print $9}') index=0 while (( $index < ${#arr_Filenames })); do Current_Filename=${arr_Filenames} ... (5 Replies)
Discussion started by: dgmm
5 Replies

7. UNIX for Dummies Questions & Answers

find the file names having specified pattern at specified position in the current directory

I would need a command for finding first 15000 of the file names whose 25th postion is 5 in the current directory alone. I do have this painful command find . -name '5*' | head -15000 | cut -c3- please refine this. Of course the above command also searches in the sub directories... (3 Replies)
Discussion started by: vk39221
3 Replies

8. Shell Programming and Scripting

How to find empty files in a directory and write their file names in a text?

I need to find empty files in a directory and write them into a text file. Directory will contain old files as well, i need to get the empty files for the last one hour only. (1 Reply)
Discussion started by: vel4ever
1 Replies

9. Shell Programming and Scripting

Help with reading directory paths with spaces from a file

Hi I want to know how to handle the spaces in the below scenario. I have a file (CON_zip_path_1.txt) which has some directory paths with spaces in directory names . My requirement is to unzip these zip files to another path. Please see the code below and the error. CON_zip_path_1.txt... (4 Replies)
Discussion started by: paul1234
4 Replies
Find::Lib(3pm)						User Contributed Perl Documentation					    Find::Lib(3pm)

NAME
Find::Lib - Helper to smartly find libs to use in the filesystem tree VERSION
Version 1.01 SYNOPSIS
#!/usr/bin/perl -w; use strict; ## simple usage use Find::Lib '../mylib'; ## more libraries use Find::Lib '../mylib', 'local-lib'; ## More verbose and backward compatible with Find::Lib < 1.0 use Find::Lib libs => [ 'lib', '../lib', 'devlib' ]; ## resolve some path with minimum typing $dir = Find::Lib->catdir("..", "data"); $path = Find::Lib->catfile("..", "data", "test.yaml"); $base = Find::Lib->base; # or $base = Find::Lib::Base; DESCRIPTION
The purpose of this module is to replace use FindBin; use lib "$FindBin::Bin/../bootstrap/lib"; with something shorter. This is specially useful if your project has a lot of scripts (For instance tests scripts). use Find::Lib '../bootstrap/lib'; The important differences between FindBin and Find::Lib are: o symlinks and '..' If you have symlinks in your path it respects them, so basically you can forget you have symlinks, because Find::Lib will do the natural thing (NOT ignore them), and resolve '..' correctly. FindBin breaks if you do: use lib "$Bin/../lib"; and you currently are in a symlinked directory, because $Bin resolved to the filesystem path (without the symlink) and not the shell path. o convenience it's faster too type, and more intuitive (Exporting $Bin always felt weird to me). DISCUSSION
Installation and availability of this module The usefulness of this module is seriously reduced if Find::Lib is not already in your @INC / $ENV{PERL5LIB} -- Chicken and egg problem. This is the big disavantage of FindBin over Find::Lib: FindBin is distributed with Perl. To mitigate that, you need to be sure of global availability of the module in the system (You could install it via your favorite package managment system for instance). modification of $0 and chdir (BEGIN blocks, other 'use') As soon as Find::Lib is compiled it saves the location of the script and the initial cwd (current working directory), which are the two pieces of information the module relies on to interpret the relative path given by the calling program. If one of cwd, $ENV{PWD} or $0 is changed before Find::Lib has a chance to do its job, then Find::Lib will most probably die, saying "The script cannot be found". I don't know a workaround that. So be sure to load Find::Lib as soon as possible in your script to minimize problems (you are in control!). (some programs alter $0 to customize the display line of the process in the system process-list ("ps" on unix). (Note, see perlvar for explanation of $0) USAGE
import All the work is done in import. So you need to 'use Find::Lib' and pass a list of paths to add to @INC. See "BACKWARD COMPATIBILITY" section for more retails on this topic. The paths given are (should) be relative to the location of the current script. The paths won't be added unless the path actually exists on disk base Returns the detected base (the directory where the script lives in). It's a string, and is the same as $Find::Lib::Base. catfile A shorcut to File::Spec::catfile using Find::Lib's base. catdir A shorcut to File::Spec::catdir using Find::Lib's base. BACKWARD COMPATIBILITY
in versions <1.0 of Find::Lib, the import arguments allowed you to specify a Bootstrap package. This option is now removed breaking backward compatibility. I'm sorry about that, but that was a dumb idea of mine to save more typing. But it saves, like, 3 characters at the expense of readability. So, I'm sure I didn't break anybody, because probabaly no one was relying on a stupid behaviour. However, the multiple libs argument passing is kept intact: you can still use: use Find::Lib libs => [ 'a', 'b', 'c' ]; where "libs" is a reference to a list of path to add to @INC. The short forms implies that the first argument passed to import is not "libs" or "pkgs". An example of usage is given in the SYNOPSIS section. SEE ALSO
FindBin, FindBin::libs, lib, rlib, local::lib http://blog.cyberion.net/2009/10/ive-done-something-bad-i-broke-backward-compatibility.html <http://blog.cyberion.net/2009/10/ive-done-something-bad-i-broke-backward-compatibility.html> AUTHOR
Yann Kerherve, "<yann.kerherve at gmail.com>" BUGS
Please report any bugs or feature requests to "bug-find-lib at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Find-Lib <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Find-Lib>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. ACKNOWLEDGEMENT
Six Apart hackers nourrished the discussion that led to this module creation. Jonathan Steinert (hachi) for doing all the conception of 0.03 shell expansion mode with me. SUPPORT &; CRITICS I welcome feedback about this module, don't hesitate to contact me regarding this module, usage or code. You can find documentation for this module with the perldoc command. perldoc Find::Lib You can also look for information at: o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Find-Lib <http://annocpan.org/dist/Find-Lib> o CPAN Ratings http://cpanratings.perl.org/d/Find-Lib <http://cpanratings.perl.org/d/Find-Lib> o RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Find-Lib <http://rt.cpan.org/NoAuth/Bugs.html?Find-Lib> o Search CPAN http://search.cpan.org/dist/Find-Lib <http://search.cpan.org/dist/Find-Lib> COPYRIGHT &; LICENSE Copyright 2007, 2009 Yann Kerherve, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.4 2011-09-17 Find::Lib(3pm)
All times are GMT -4. The time now is 05:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy