Sponsored Content
Top Forums UNIX for Dummies Questions & Answers List directories, subs and files Post 302510573 by dakke on Monday 4th of April 2011 11:32:42 AM
Old 04-04-2011
@vgersh99

You did, untill I noticed that the output was not as desired for some files (posted in previous reply). Your output with your code
Quote:
find . -ls |nawk '{match($0,":[0-9][0-9]*");f=substr($0,RSTART+3);match(f,"/[^/]*$");print$1,$3,f,substr(f,RSTART+1)}'
was:
Quote:
1223405;120; ./Folder/Folder/Folder/file.pdf;file.pdf
2539552;40; ./File;File.odt
1519496;0; ./Folder2;Folder2
1519497;0;19497 0 drwxr-xr-x 9 user staff 306 24 okt 2009 ./Virtual Machines.localized/.localized;.localized
1519504;8;19504 8 -r--r--r-- 1 user staff 92 24 okt 2009 ./Folder3/.Folder/de.strings;de.strings
1519503;8;19503 8 -r--r--r-- 1 user staff 86 24 okt 2009 ./Folder3/.Folder/en.strings;en.strings
the issue here is that (last line):
'19503' should not be there, neither should the ' -r--r--r--'. Therefore I applied the other code.

@ ctsgnb
This for now seems to work, will try and report back if not.
Code:
find . -ls | awk '{type=($3~/^d/)?"directory":($3~/^-/)?"file":($3~/^l/)?"link":"other";x=y=$0;sub(".*"$10,"",x);sub(".*"$10"[^/]*/","",y);sub(".*",$1 FS type FS x FS y ,$0)}1'

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List specific files from directories

Hello, I would like to list the files from all directories that has been modified more than 1 month ago, and whose name is like '*risk*log'. I think a script like this should work : ls -R | find -name '*risk*.log' -mtime 30 -type f But it tells me "no file found" though I can see some. ... (4 Replies)
Discussion started by: Filippo
4 Replies

2. UNIX for Dummies Questions & Answers

List directories and files

I want to count how many levels there are under a directory. I repeat level. Also how i count only all the files in a directoy ( all files of all directories of all leves down!) and how can i count only all the directories under a directory (including subdirectories, all levels down) ... (2 Replies)
Discussion started by: psalas
2 Replies

3. Shell Programming and Scripting

Command to list only files omit directories.

Hi All I am writting a script that does a comparison between files in 2 diffectent directories. To do this I need a command that will list out only the files in a give directory and omit any sub dorectories with that directory. But I am unable to find it. Please Help. I tried ls... (5 Replies)
Discussion started by: Veenak15
5 Replies

4. Shell Programming and Scripting

How to get a list of files in a dir w/o sub-directories?

Hi I am looking for the correct syntax to find all files in the current directory without listing sub-directoris. I was using the following command, but it still returns subdirectoris and files inside them: $ ls -laR | grep -v ^./ Any idea? Thanks PS I am in ksh88 (4 Replies)
Discussion started by: aoussenko
4 Replies

5. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

6. UNIX for Dummies Questions & Answers

list directories with more than X files

I want to search a server beginning at /home and list directories with more than X files I found a hack that injects tons of files into a directory How can I search the server recursively and list directories with more than X files? Thank you! like, find /home (directories, that meet the... (5 Replies)
Discussion started by: vanessafan99
5 Replies

7. UNIX for Dummies Questions & Answers

List biggest files (Not Directories)

Hello, can you please help me writing a command that would output the biggest files on my system from biggest to smallest? I want this to print only the files, not the directories. I have tried du -a ~ | sort -nr | head -10 However, this also prints out all the directories - which I do... (8 Replies)
Discussion started by: tonydaniels1980
8 Replies

8. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

9. Shell Programming and Scripting

List directories and count files inside

I'm trying to make a script that will list all directories under a selection as well as the number of files in each. I cannot get it to work under a symbolic link. The file structure is: XXX_20131127_001 dir01 (sym link) 2404x912 file.0000.xxx to ... (10 Replies)
Discussion started by: scribling
10 Replies

10. Solaris

A way to list directories that contain specific files.

Hi everyone My issue is this, I need to list all the sub directories in a directory that contains files that have the extension *.log, *.dat and *.out . After reviewing the output i need to delete those directories i do not need. I am running Solaris 10 in a bash shell. I have a script that I... (2 Replies)
Discussion started by: jsabo40
2 Replies
File::LocalizeNewlines(3pm)				User Contributed Perl Documentation			       File::LocalizeNewlines(3pm)

NAME
File::LocalizeNewlines - Localize the newlines for one or more files DESCRIPTION
For people that routinely work with a mixture of different platforms that have conflicting newline formats (mainly *NIX and Win32) there are a number of different situations that can result in files having their newlines get corrupted. File::LocalizeNewlines provides a mechanism for one off or bulk detection and conversion of these files to the newline style for the local platform. The module implements the conversion using a standard "universal line seperator" regex, which ensures that files with any of the different newlines, plus a couple of common "broken" newlines, including multiple different types mixed in the same file, are all converted to the local platform's newline style. METHODS
new param => value, ... The "new" constructor creates a new conversion object. By default, the conversion object will process all files and convert them to the local platform's newline format. Takes some optional parameters filter => File::Find::Rule The "filter" param allows you to provide an instantiate File::Find::Rule object, that will used to determine the list of files to check or process. newline => $newline The "newline" option allows you to provide an alternative newline format to the local one. The newline format should be provided as a literal string. For example, to force Win32 newlines, you would use my $Object = File::LocalizeNewlines->new( newline => "1512" ); verbose => 1 The "verbose" option will cause the "File::LocalizeNewlines" object to print status information to "STDOUT" as it runs. Returns a new "File::LocalizeNewlines" object. Find The "Find" accessor returns the File::Find::Rule object that will be used for the file search. newline The "newline" accessor returns the newline format that will be used in the localisation process. localized $file The "localized" method takes an argument of a single file name or file handle and tests it to see it is localized correctly. Returns true if localized correctly, false if not, or "undef" on error. find $dir The "find" method takes the path for a dir (or file) and returns a list of relative files names for all of the files that do not have their newlines correctly localized. Returns a list of file names, or the null list if there are no files, or if an incorrect path was provided. localize $file | $dir The "localize" method takes a file, file handle or directory as argument and localizes the newlines of the file, or all files within the directory (that match the filter if one was provided). Returns the number of files that were localized, zero if no files needed to be localized, or "undef" on error. SUPPORT
Bugs should always be submitted via the CPAN bug tracker <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-LocalizeNewlines> For other issues, contact the maintainer. AUTHOR
Adam Kennedy <adamk@cpan.org> ACKNOWLEDGEMENTS
Thank you to Phase N (<http://phase-n.com/>) for permitting the open sourcing and release of this distribution. FileHandle support added by David Dick <ddick@cpan.org> COPYRIGHT
Copyright 2005 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.10.0 2009-06-25 File::LocalizeNewlines(3pm)
All times are GMT -4. The time now is 05:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy