General :: Listing Files Recursively, Sorted By Time, Limited Head?

Mar 24, 2011

I'm trying to make a shell script that will list the 50 newest files in a directory with several subdirectories in. I've been trying with the find-command with no luck and now I've figured I should probably use ls. The problem is when I do "ls -lRt | head -50" it will do 1 directory at the time. It will not first make the full list and then sort it. This will display all items in first directory, sorted, then the newest directory will be sorted and displayed. So I figured I have to sort the whole process of ls before I limit the head. So this is where I am at now: ls -lRt | sort <something clever here> | head -50

Only doing a "|sort|" will sort it by name if I understand it right and I don't know how to solve it. Here's also my first attempt if that is of any interrest or help, this was limited by the change status time of files (so some lists got very large). These lists dit not get sorted by time and I could not find any way to do so.find $ftpDir -ctime $time -type f -print > $ftpFileLsAny help on this would be appreciated since I'm sort of stuck now. After reading manuals for all the options I can think of and still there's just a big blur in my head..

View 12 Replies


ADVERTISEMENT

General :: Command For Listing Files/dirs Recursively Of Specific Directories?

Jul 22, 2011

suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ? I would like to do this in Solaris 10 and Linux(RHEL 5.x).

View 3 Replies View Related

General :: Get The Last Change Time Of Directory Recursively

May 28, 2011

How can I get the last time any of the files in a directory or its subdirectories has changed?
e.g

Dir - changed 1/1/1
Sub Dir 1 - changed 2/1/1
Sub Dir 2 - changed 3/1/1
File 1 - changed 10/1/1
File 2 - change 5/1/1


The output for this for Dir should be 10/1/1 (File 1 was the last modified one). Getting the last file name to be modified is a bonus but isn't necessary.

View 3 Replies View Related

General :: How To Change Modification Time (Created Recursively)

Jul 1, 2009

I know there exists a touch command to change the date of the files. However, I want to change the files of a directory and the directory time. Is there a command like -R. Please provide me an example of the command?

View 4 Replies View Related

General :: Recursively Cp All Directories, Files And Hidden Files?

May 17, 2010

Ubuntu 10.04

I want to copy all directories, files, and hidden files and hidden directories with one command. I want these items to replace any same items in the target directory.

I have tried several things, such as:

cp -r *
cp -aR *

but I only seem to get visible files and directories. Obviously, I am missing something. (A brain, probably....)

View 9 Replies View Related

CentOS 5 :: Useradd Command - Finding 10 Last Files Sorted

Apr 6, 2009

I work under centos 5, I would like to know which command to use in order to find where the useradd command is geinstalled. Second How can I find the 10 last files sorted (reverse) from the /etc directory.

View 2 Replies View Related

General :: Listing All Linked Files

Jan 21, 2010

I can't seem to find a way to do this, so maybe it's not actually possible, but I was wondering if there was a way to list all files that link to a file.

For example.

touch a
ln a b
ln a c

I want to find out what files link to a (not symlinks, mind you), assuming that this is more complicated (they are spread around to different directories).

I kind of understand about the filesystem storing links in one area and data in another, so I understand it probably takes more work to find a link from a file location than the other way around.

View 1 Replies View Related

General :: Listing Files Whose Contain A String?

May 5, 2010

following can be used to locate files that contain the contents 'SomeString' or 'SomeOtherString':

Code:

find /home/username/public_html -type f -print0 | xargs -0 egrep -l 'SomeString|SomeOtherString'

How would I limit this to searching for the text 'SomeString' or 'SomeOtherString', but only if the file has extension .php, .inc or .js? Also - what piping to xargs does here? I don't understand how this command actually works.

View 3 Replies View Related

General :: Listing Files Using Pattern Matching

Mar 13, 2011

I have a requirement to list files using find command My folder contains below list of files with out extention.I have a requirement to exclude only ABC.123.* type files and list others. Even though files having MNO contains this pattern i should not exclude. Even if file ends with .txt or .doc it should not be excluded. That is ABC.123.1234.txt should not be excluded.But I am not getting what is required. Can any one please let me know if I am doing wrong any where. As per my requirement I cannot use grep, -regex, or -regex attributes to find command.

View 7 Replies View Related

General :: Recursively Count All The Files In A Directory?

Oct 12, 2010

I have a really deep directory tree on my Linux box. I would like to count all of the files in that path, including all of the subdirectories.

For instance, given this directory tree:

/home/blue
/home/red
/home/dir/green
/home/dir/yellow
/home/otherDir/

If I pass in /home, I would like for it to return 4 files. Or, bonus points if it returns 4 files, 2 directories. Basically, I want the equivalent of right-clicking a folder on Windows and selecting properties and seeing how many files/folders are contained in that folder.

How can I most easily do this? I have a solution involving a Python script I wrote, but why isn't this as easy as running ls | wc or similar?

View 5 Replies View Related

General :: Removing Files Or Directories Recursively

Jan 29, 2010

The rm command man pages discusses removing files or directories recursively. So what is meant by deleting a file or directory recursively? And what are some reasons for doing so?

View 3 Replies View Related

General :: List Contents Of All Files Recursively?

Jan 22, 2011

What I would like to do is to print the contents of all text files in a particular directory, recursively. Problem being that there are directories and possibly binaries scattered around in the filesystem as well.

Trying cat * works as long as there are no directories in there, but when there are it gives an error instead and prints nothing.

I'm sure it's easy using file -f or something but I can't figure it!

View 8 Replies View Related

General :: Script To Rename Files Recursively?

May 8, 2011

I'm planning to writing a script to rename files recursively.

To be said that I'm using /bin/sh (not /bin/bash) as this is the only shell available on the busybox of the linux router (tomato) I'm using.

Basically I would like to rename files with extension .jpg using as a suffix the filename of another file in the very same directory with extension .avi

The reason for this is because pretty much all the DLNA devices like modern TV playing .avi files will display a thumbnail of the video when browsing the filesystem, however to do so they'll need .jpg image wit hthe same filename of the video in the very same directory.

View 3 Replies View Related

General :: How To Recursively Find Files Over Certain Size

Apr 15, 2010

I made an account under freeshell.org and it has been very satisfactory so far. I recommend everyone getting an account under freeshell.org. But anyways, how do I find files over, for example, 500 KB, in the entire, my shell account?

View 1 Replies View Related

General :: Listing Files Selectively And Then Zipping Them?

Oct 4, 2010

I need to list the files only from 23:00 to 23:30 on 3rd oct 2010 from a directory and then zip them and have it.how to execute the same.

View 5 Replies View Related

General :: Listing Pdf Files In A Folder On The Desktop?

Mar 24, 2011

its a very basic question but iam not getting it right nowi have to list all the pdf files on my desktop even the pdf files which are present in folders on the desktopls *.pdfonly list the files present on the desktop, but not the files in the folders on the desktop containing the pdf files.

View 3 Replies View Related

General :: Recursively Searching PHP Or HTML Files

May 5, 2010

I'm a frequent user of grep. I know that I can recursively search a directory using the -r flag:
Code:
// will recursively search all files
grep -r 'some string' *

However, if I want to limit my search to PHP files, the -r flag is suddenly useless:
Code:
// for some reason, this only searches the PHP files in the current dir
grep -r 'some string' *.php

Any good way to recursively search a directory and its subdirs for a string but ONLY look at PHP or HTML files (and possibly TXT files too) ? I'm really hoping for a nice, short command that doesn't involve using an exclude file and which isn't really painful to type. I do this kind of search very frequently and have resorted to either searching EVERY file which is really slow (TAR and ZIP files really slow it down) OR typing repeated commands to search *.php, */*.php, etc.

View 6 Replies View Related

General :: List Recursively All Files With Timestampsand Fullpath?

Jan 3, 2011

I want to list recursively all files in given direcotry, with their fullpath and their timestamps.Something like this:10:30 Dec 10 2010 /tmp/mydir/myfileI've tryied with:find . -type f -exec ls -la {} ;but that don't give me the fullpath.

View 3 Replies View Related

General :: How Do I Recursively Delete Duplicate Files Using Terminal

Mar 1, 2011

I'm using a mac, and just transferred a bunch o photos from another computer, and as it turns out, there is a bunch of duplicates.I'm not too familiar with the mac terminal, but if there is a solution for linux, it will probably work for the mac.Just need to be able to recursively scan all folders in my Pictures folder and then Delete them.

View 1 Replies View Related

General :: Command Line - Compressing All .pdf Files Recursively (.tar)?

Jun 20, 2011

At the linux command line, I'd like to compress all .pdf files in a directory, any of it's subdirectories and so on - but only .pdf files. I'm struggling to figure out the syntax

View 2 Replies View Related

General :: List Folders By The Number Of Files Recursively

Aug 11, 2011

Is there any Linux application for finding the folders with the most number of files? baobab sorts folders by their total size, I'm looking for a tool that lists folders by the total number of files in it.

The reason I'm looking is because copying tens of thousands of small files is excruciatingly slow (much slower than copying a few large files of the same size), so I want to archive or delete those folders with high file counts that that will be slowing down the copying (it won't speed things up now, but it would be faster when I need to move/copy it again in the future).

View 5 Replies View Related

General :: Recursively Add Read Privilege To All The Files Under A Certain Directory?

Jan 18, 2010

I'm under linux . by default, other user can't read anything under my home directory. let's see my home directory is /home/superman , and I tried to use

chmod +r /home/superman

to let others can acess files under my home directory , but it does not work .

View 1 Replies View Related

General :: Script To Mass Rename Files Recursively?

Sep 9, 2009

I need a either a script or perl script that will allow me to mass rename files, folders, and sub folders. I need to replace special chars in the current file names with underscores. I was able to make this happen in a single directory, but not recursively.

Here is what does it in a single directory.

for file in *
do
mv "$file" $(echo "$file" | sed 's/[^A-Za-z0-9_.]/_/g')
done

View 8 Replies View Related

General :: Listing Directory And Files' Permission Into Numbers?

Jul 20, 2010

Is it possible for listing directory and files' permission into numbers?

Generally ls command shows directory and files' permission as follows;

[root:maestro:/home/ddisk_net]# ls -al
Total 44
drwx------ 4 ddisk_net users 4096 7월 20 10:40 .
drwxr-xr-x 21 root root 4096 7월 20 10:28 ..
-rw------- 1 ddisk_net webteam 5 7월 20 10:40 .bash_history
-rw-r--r-- 1 ddisk_net users 33 1월 22 2009 .bash_logout

[code].....

View 9 Replies View Related

General :: Awk / Grep Or Sed - Find And Replace Recursively From Files

Feb 12, 2010

I am new to linux as well as awk, grep or sed. I need a find and replace command single liner or script that loops trough input file (file1) and find the particular input in file2 and add "!" in front of the found string.

Example:
input file: file1
g+h=o+p
a+b=c+d
file2 (file that need to look for)
a+b=c+d1e105
x+y=z+s5e105
g+h=o+pabcdefg
t+r=w+qxvyderf

Output file (file3 should look like this)
!a+b=c+d1e105
x+y=z+s5e105
!g+h=o+pabcdefg
t+r=w+qxvyderf

I have tried many awk and sed method of find and replce but it did not work the way I wanted. This is mainly due to my lack of experience in awk and sed. The program should loop trough file1 and find in file2 and output in file3 for the 1st (g+h=o+p) set then repeat the same process again for set 2 (a+b=c+d).

View 14 Replies View Related

General :: Recursively Remove Subdirectories And Files But Not The First Parent Directory?

Feb 11, 2010

I'm able to use the following to remove the target directory and recursively all of its subdirectories and contents. find '/target/directory/' -type d -name '*' -print0 | xargs -0 rm -rf

However, I do not want the target directory to be removed. How can I remove just the files in the target, the subdirectories, and their contents?

View 4 Replies View Related

General :: Overwriting Specific Files In Directory Tree Recursively

Jul 19, 2011

I would like to overwrite files in a directory tree, recursively. The ones I would like to overwrite match the filename "x_alpha*.png" and have a size exactly 456 bytes. Is there any way to search for these recursively in a directory tree, and overwrite them with a reference file, for example "e:mydirgood.png"

I am using Windows 7, but I have UnxUtils, so I can use those too. What I am looking for is something like this, generated automatically:
copy /y e:mydirgood.png e:mydiracx_alpha0023.png
copy /y e:mydirgood.png e:mydirefgx_alpha0045.png
copy /y e:mydirgood.png e:mydirhx_alpha0248.png

View 2 Replies View Related

General :: Rsync Files Recursively But Place In One Remote Directory?

Jan 29, 2011

i would like to find and backup all *.mp4 files from /Pictures and its sub-directories and move them to a single directory on a remote. I can find and move the files but I don't want the directory structure...just the files to be placed in the remote directory.

To find my files I use

rsync -r -a -v -e "ssh -l user" --delete --include '*/' --include '*.mp4' --exclude '*' /home/drew/Pictures/ remoteserver:/Users/drew/mp4

but this creates all the subdirectories

I also tried

find ~/Pictures -name "*.mp4" -exec rsync -r -a -v -e "ssh -l user" --delete {} remote:/Users/drew/mp4 ;

This works but takes forever

View 3 Replies View Related

General :: Make All Files Non-executable Recursively Using Find Without Affecting Directories?

Sep 26, 2010

I need to strip the executable flag from all files within a certain directory and sub directories. Right now I'm doing it with a 2 step process

find /dir/ -type f -exec chmod ugo-x {} ;
find /dir/ -type d -exec chmod ugo+rx {} ;

Is it possible to modify the first line so that I can strip exec flag from all non-directory files? Since this needs to be done on a fairly regular basis across a lot of directories and files, I'd prefer not to use a bash script which would slow it down.

View 1 Replies View Related

General :: Change A String Recursively In Files Located In Folders And Subfolders?

Jul 22, 2011

lets say I have a project that have generated lots of xml files. Though all these xml files point to a location with the text name TEXT15. I want to change all the files that containts TEXT15 and change it to TEXT16. This actually works for files in a folder but not recursively in all the entire files....perl -pi -c 's/TEXT15/TEXT16/g' ./* but I have many subfolders and within this more subsub folders....i just want to do this recursively.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved