Sponsored Content
Top Forums Shell Programming and Scripting Sorting a list of filenames but keeping the path information. Post 302533328 by Bashingaway on Thursday 23rd of June 2011 10:11:53 AM
Old 06-23-2011
Sorting a list of filenames but keeping the path information.

Hi All

I've googled around for this and can't see a way of doing it.

I have a file that contains a number of records that are layed out something like the following.

/path/to/directory/that/contains/a/file/I/need/filename.pdf

The path itself can vary both in terms of the names and the number of subdirectories before I get to the file.

I realise I can use basename to extract the filename and do a sort but what I want to do is to sort the list using the filename as the key and then find duplicate filenames and then identify the paths of the conflicting filename.

I also want to be able to do a quick and dirty compare from the command line something like

Code:
cat /the/input/file | sed -e 's\: delete up to the last forward slash in the path to leave just the filename ::' | sort | uniq

To allow me to do a fast visual confirmation on if there are duplicates in the file. I can't see a way to get sed to delete up to the last instance of a specific character on a line (basename won't work from the command line as there's multiple records in the input file so it needs a loop).

All ideas gratefully received.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Sorting filenames by order in another file

I would like to arrange /sort filenames ending with suffix like ".00XXXX". where X is a digit. However the order of arrangement is in a text file and is 'harpharzard'. e.g the text file may be like 002345 009807 001145 I wanted to avoid doing this using sql and exporting the text file back to... (4 Replies)
Discussion started by: samudimu
4 Replies

2. Shell Programming and Scripting

copying unreference files and keeping absolute path

Hi guys, I'm creating a script that basically remove unreference files so at the moment I have something like: DAYS=30 for DIRECTORY in `mount | awk '{ print $7}'` do find $DIRECTORY -type f -atime +$DAYS < ~/files.log done for FILE in `awk '{print $1}' ~/files.log` do cp... (2 Replies)
Discussion started by: hariza
2 Replies

3. UNIX for Advanced & Expert Users

help with sorting sequence in Unix C:sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list

Hi List is 000|2008-07-17|556543|RTJ|35-RTGJ|EYT 465|2008-11-10|567789|GHJ|45-DGHH|ETU 533|2008-09-06|567789|GHJ|45-DGHH|ETU How does it do it? sort -t ':' +0 -1 -n +1 -2 +2 -3 -o list list (6 Replies)
Discussion started by: gurvinder
6 Replies

4. Shell Programming and Scripting

Sorting by Full directory path

I have a text file with full list of files with their full path. I wanted to sort it by directory then files then subdirectory by alphabetically. When I used the sort command it doesn't give like what I want. Could somebody help me on this. Here is the ex: This is what I'm getting... (2 Replies)
Discussion started by: javidraaj
2 Replies

5. Shell Programming and Scripting

Truncate path and keep only filenames

Hi everyone, I have a question for you, I'm trying to create a script that will automate creating loading screens for the iPhone. So what I need to do, is list the directories inside /var/mobile/Applications and scan inside those, for the .app directory inside each. Take that .app name... (15 Replies)
Discussion started by: kicker75
15 Replies

6. UNIX for Dummies Questions & Answers

Prepending information from filenames into files

I would like to know how to take information from a filename and place it into the text of the same file. Let's say I have a file called height_2_width_1.txt containing data that is related to a height of 2 and a width of 1, and the text originally looks like this: where these two columns... (13 Replies)
Discussion started by: Scatterbrain26
13 Replies

7. UNIX for Dummies Questions & Answers

Sorting of alphanumeric filenames..

Hi All, I want sort following files in ascending order. exp_installer_CC4160-file10.dmp exp_installer_CC4160-file11.dmp exp_installer_CC4160-file12.dmp exp_installer_CC4160-file13.dmp... (3 Replies)
Discussion started by: gramakrishna
3 Replies

8. Shell Programming and Scripting

print all filenames in directory with path to another file

hi, i have a directory at /path/unix with the following files 1.txt 2.txt 3.txt 4.txt I want to make another file called filenames.txt at a different location called /path/home. So, my output file would be /path/home/filenames.txt with contents /path/unix/1.txt... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

9. Shell Programming and Scripting

Sorting group information for accounts

I have an input file that contains the primary and secondary groups a user should have based on a pre-defined role. The input file looks like this: <user_login>|<comment_field>|<role> After I execute my script to do some grepping I have the following user file where the secondary groups are... (10 Replies)
Discussion started by: MaindotC
10 Replies

10. Shell Programming and Scripting

Sorting using filename of a path

Hi all! i have a question how do you sort the filename of a path directory according to alphabetic order. Example: sort according to highlighted text. There maybe space for filename Path=/home/pikamon/Desktop/ABC; Path=/home/pikamon/Desktop/ABD; Path=/home/pikamon/Desktop/Riduan la;... (5 Replies)
Discussion started by: pikamon
5 Replies
FAILLOCK(8)							 Linux-PAM Manual						       FAILLOCK(8)

NAME
faillock - Tool for displaying and modifying the authentication failure record files SYNOPSIS
faillock [--dir /path/to/tally-directory] [--user username] [--reset] DESCRIPTION
The pam_faillock.so module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than deny consecutive failed authentications. It stores the failure records into per-user files in the tally directory. The faillock command is an application which can be used to examine and modify the contents of the the tally files. It can display the recent failed authentication attempts of the username or clear the tally files of all or individual usernames. OPTIONS
--dir /path/to/tally-directory The directory where the user files with the failure records are kept. The default is /var/run/faillock. --user username The user whose failure records should be displayed or cleared. --reset Instead of displaying the user's failure records, clear them. FILES
/var/run/faillock/* the files logging the authentication failures for users SEE ALSO
pam_faillock(8), pam(8) AUTHOR
faillock was written by Tomas Mraz. Linux-PAM Manual 06/17/2014 FAILLOCK(8)
All times are GMT -4. The time now is 08:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy