Sponsored Content
Operating Systems Linux How to print full path name along with file extension? Post 303007261 by lijjumathew on Tuesday 14th of November 2017 04:19:50 PM
Old 11-14-2017
How to print full path name along with file extension?

Hi

I have a requirement like this:
Code:
/abc/a/x.txt
/abc/a/y.txt
/abc/b/x.gz
/abc/b/y.txt

I need output like this:
Code:
/abc/a:*.txt
/abc/b:*.txt
/abc/b:*.gz

I have tried
Code:
 find /abc -type f -name "*.*" ||awk -F . '{print $NF}'

it is print only extensions without path name.

Please advice!

Thanks

Last edited by jim mcnamara; 11-14-2017 at 05:28 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

process executable file full path

hi guys i give "ps -ef | grep some_executable_file" on the command line. this "some_executable_file" resides on many paths which r included in the PATH environment variable, so the output depicts only "some_executable_file" in the COMMAND column. how can i get the full path? thanx (3 Replies)
Discussion started by: xtrix
3 Replies

2. UNIX for Advanced & Expert Users

list all files with full path of the file

How can i list every single file on a sun solaris server running 2.8 starting from '/' with the full path included in it? example. / ... ... ... /etc/inetd.conf /etc/passwd /etc/shadow ... ... ... /var/adm/messages /var/adm/messages.0 /var/adm/messages.1 ... ... ...... (4 Replies)
Discussion started by: Sowser
4 Replies

3. Shell Programming and Scripting

to find the file with full path

Hi, I have written this shell script: fl=`ls -1lrt $mylist | grep '\.xml$' | awk '{print $9}'` echo $fl (1) for i in $fl do for dir in $mylist do if then echo $dir/$i >> tmp (2) fi done done The mylist contains some directory names. The satement (1) gives the sorted list... (5 Replies)
Discussion started by: surjyap
5 Replies

4. Shell Programming and Scripting

list file with full path

This has been bugging me for a while. How can i list file to show full path. /directory/test $ ls file.tst file.tst $ desired output: /directory/test/file.tst (2 Replies)
Discussion started by: ryandegreat25
2 Replies

5. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

6. Shell Programming and Scripting

Retrieve directory path from full file path through sh

Hi, I have a file abcd.txt which has contents in the form of full path file names i.e. $home> vi abcd.txt /a/b/c/r1.txt /q/w/e/r2.txt /z/x/c/r3.txt Now I want to retrieve only the directory path name for each row i.e /a/b/c/ /q/w/e/ How to get the same through shell script?... (7 Replies)
Discussion started by: royzlife
7 Replies

7. Shell Programming and Scripting

Return Full File Path To Array PERL

Iam trying to load the full path of multiplie files in the same directory to an array if the filenames matches a pattern. The following is the current code; where $input=C:\test # change to and open the comparison directory chdir("$input2") || die "Cannot change dir: $!"; opendir(DIR2,... (2 Replies)
Discussion started by: cold_Que
2 Replies

8. Shell Programming and Scripting

How to extract strings from full path when full path is not fixed

/Path/snowbird9/nrfCompMgrRave1230100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird6/nrfCompMgrRave1220100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird14/nrfCompMgrRave920100920.log.gz:09/20/2010 06:14:51 ERROR Error Message.... (0 Replies)
Discussion started by: Shirisha
0 Replies

9. Shell Programming and Scripting

Grep File Full Path in a file

Hi, I would like to know how to grep all the paths in a file having extension .BMP For e.g. File Name : sample.txt File Content : xxxxxxxxxxxxxxxxx xxxxx/root/cdrive/picure.BMP xxxx xxxxxxxxxxx xxxxx/root/ddrive/picure.BMP xxxx xxxxxxxxxxx Expected Output : ... (4 Replies)
Discussion started by: vdivb
4 Replies

10. Shell Programming and Scripting

Bash to trim folder and files within a path that share a common file extension

The bash will trim the folder to trim folder. Within each of the folders (there may be more than 1) and the format is always the same, are several .bam and matching .bam.bai files (file structure) and the bashunder that executes and trims the .bam as expected but repeats the.bam.bai extentions... (9 Replies)
Discussion started by: cmccabe
9 Replies
Data::Compare(3)					User Contributed Perl Documentation					  Data::Compare(3)

NAME
Data::Compare - compare perl data structures SYNOPSIS
use Data::Compare; my $h1 = { 'foo' => [ 'bar', 'baz' ], 'FOO' => [ 'one', 'two' ] }; my $h2 = { 'foo' => [ 'bar', 'barf' ], 'FOO' => [ 'one', 'two' ] }; my @a1 = ('one', 'two'); my @a2 = ('bar', 'baz'); my %v = ( 'FOO', @a1, 'foo', @a2 ); # simple procedural interface print 'structures of $h1 and \%v are ', Compare($h1, \%v) ? "" : "not ", "identical. "; print 'structures of $h1 and $h2 are ', Compare($h1, $h2, { ignore_hash_keys => [qw(foo)] }) ? '' : 'not ', "close enough to identical. "; # OO usage my $c = new Data::Compare($h1, \%v); print 'structures of $h1 and \%v are ', $c->Cmp ? "" : "not ", "identical. "; # or my $c = new Data::Compare; print 'structures of $h and \%v are ', $c->Cmp($h1, \%v) ? "" : "not ", "identical. "; DESCRIPTION
Compare two perl data structures recursively. Returns 0 if the structures differ, else returns 1. A few data types are treated as special cases: Scalar::Properties objects This has been moved into a plugin, although functionality remains the same as with the previous version. Full documentation is in Data::Compare::Plugins::Scalar::Properties. Compiled regular expressions, eg qr/foo/ These are stringified before comparison, so the following will match: $r = qr/abc/i; $s = qr/abc/i; Compare($r, $s); and the following won't, despite them matching *exactly* the same text: $r = qr/abc/i; $s = qr/[aA][bB][cC]/; Compare($r, $s); Sorry, that's the best we can do. CODE and GLOB references These are assumed not to match unless the references are identical - ie, both are references to the same thing. You may also customise how we compare structures by supplying options in a hashref as a third parameter to the "Compare()" function. This is not yet available through the OO-ish interface. These options will be in force for the *whole* of your comparison, so will apply to structures that are lurking deep down in your data as well as at the top level, so beware! ignore_hash_keys an arrayref of strings. When comparing two hashes, any keys mentioned in this list will be ignored. CIRCULAR STRUCTURES
Comparing a circular structure to itself returns true: $x = $y; $y = $x; Compare([$x, $y], [$x, $y]); And on a sort-of-related note, if you try to compare insanely deeply nested structures, the module will spit a warning. For this to affect you, you need to go around a hundred levels deep though, and if you do that you have bigger problems which I can't help you with ;-) PLUGINS
The module takes plug-ins so you can provide specialised routines for comparing your own objects and data-types. For details see Data::Compare::Plugins. Plugins are *not* available when running in "taint" mode. You may also make it not load plugins by providing an empty list as the argument to import() - ie, by doing this: use Data::Compare (); A couple of functions are provided to examine what goodies have been made available through plugins: plugins Returns a structure (a hash ref) describing all the comparisons made available through plugins. This function is *not* exported, so should be called as Data::Compare::plugins(). It takes no parameters. plugins_printable Returns formatted text EXPORTS
For historical reasons, the Compare() function is exported. If you don't want this, then pass an empty list to import() as explained under PLUGINS. If you want no export but do want plugins, then pass the empty list, and then call the register_plugins class method: use Data::Compare (); Data::Compare->register_plugins; or you could call it as a function if that floats your boat. SOURCE CODE REPOSITORY
<git://github.com/DrHyde/perl-modules-Data-Compare.git> BUGS
Plugin support is not quite finished (see the TODO file for details) but is usable. The missing bits are bells and whistles rather than core functionality. Please report any other bugs either by email to David Cantrell (see below for address) or using rt.cpan.org: <https://rt.cpan.org/Ticket/Create.html?Queue=Data-Compare> AUTHOR
Fabien Tassin <fta@sofaraway.org> Portions by David Cantrell <david@cantrell.org.uk> COPYRIGHT and LICENCE Copyright (c) 1999-2001 Fabien Tassin. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Some parts copyright 2003 - 2013 David Cantrell. Seeing that Fabien seems to have disappeared, David Cantrell has become a co-maintainer so he can apply needed patches. The licence, of course, remains the same. As the "perl licence" is "Artistic or GPL, your choice", you can find them as the files ARTISTIC.txt and GPL2.txt in the distribution. SEE ALSO
perl(1), perlref(1) perl v5.18.2 2013-09-26 Data::Compare(3)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy