The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
trim spaces in a file badrimohanty Shell Programming and Scripting 7 06-22-2009 02:53 PM
eliminate pathname from the file name in the o/p ss_ss Shell Programming and Scripting 2 02-24-2009 02:31 AM
How to trim a 419th column in UNIX file. Amit.Sagpariya Shell Programming and Scripting 4 01-14-2009 02:09 AM
trim file tungaw2004 UNIX for Dummies Questions & Answers 1 09-15-2007 07:05 AM
trim file name extension???? vishal_ranjan AIX 1 07-31-2007 10:34 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-16-2009
Sangtha Sangtha is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 18
Trim pathname of the file

I am capturing the files in a directory to an array. I have 2 arrays with list of files in two different directories. Both the directories are supposed to have the same number of files and filenames.

I want to check that the same file exists in both the directories. After I capture the filenames in Array, I see that the file names are captured along with their pathname. So when I compare the filenames, I think the system takes the pathname into account and fails the match.

Here is what I have:

dir1 = aa/bb/cc/dd/ee
dir2 = xx/yy/ww/uu/vv/zz/tt/ss

array1=($(find "$dir1" -name "out_*" | sort -n))
array2=($(find "$dir2" -name "out_*" | sort -n))

Output looks like:
Array1 = aa/bb/cc/dd/ee/out_abcd.txt
Array2 = xx/yy/ww/uu/vv/zz/tt/ss/out_abcd.txt

When comparing these outputs I get error.
Any help would be appreciated.

Thanks!
  #2 (permalink)  
Old 07-16-2009
pludi's Avatar
pludi pludi is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,972
man 1 basename
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0