3

Here are the specs: Find all files in / modified after the modification time of /tmp/test, exclude /proc and /sys from the search, and print the full path of the file along with human readable size. Here is what I have so far:

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -exec ls -lh {} \; | less

The issue is that the full path doesn't get printed. Unfortunately, ls doesn't support printing the full path! And all solutions I have found that show how to print the full path suggest using find. :|

Any ideas? Thanks!

5

Instead of -exec ls -lh {} \; you can also use the printf option:

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -printf "%s %p\n" | less

Although that will just print the size in bytes and not in the nice human-readable format ls supports.

| improve this answer | |
  • 1
    +1 for POSIX and non-ls solution. – l0b0 Jun 25 '13 at 7:55
1

Add -d to the ls command.

find / \( -path /proc -o -path /sys \) -prune -o -newer /tmp/test -exec ls -lhd {} \; | less

That will also fix the problem you were bound to have with files showing up twice in your list.

| improve this answer | |
0

I too enjoy my fullpaths, so I've ended up creating few aliases just for such an occasion: alias ldf='ls $PWD/* -dF' alias lfp='ls $PWD/* -daFc --group-directories-first' alias lfh='ls $PWD/.* -daFc --group-directories-first' alias lafp='ls $PWD/.* $PWD/* -daFc --group-directories-first' And just simply store 'em to $HOME/.bashrc (these already follow the syntax of .bashrc) Though, if one wants to copy+paste the code to terminal (Not a recommended practice, but I'm not your guardian, so:) Here is a direct paste for .bashrc:

echo " alias ldf='ls $PWD/* -dF' alias lfp='ls $PWD/* -daFc --group-directories-first' alias lfh='ls $PWD/.* -daFc --group-directories-first' alias lafp='ls $PWD/.* $PWD/* -daFc --group-directories-first'" >> ~/.bashrc

All of these are basically for the same goal, with minor tweaks for specific purposes; like: ldf=List Directorys Files, lfp= List Full Path -organizing flag used, lfh= List Full Hidden, And last; for all the users and porpoises: lafp = List All-Full Path(both hidden and regulars)

| improve this answer | |
  • The day you need to use some other system or user, it will bite you. – vonbrand Aug 8 '19 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.