Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Lubuntu - script for "recently used" files

  1. #11
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Lubuntu - script for "recently used" files

    @Kevin McCready
    I suppose the filesystem of your /home is ext4? Because I'm not sure how mtime/ctime/atime would work say on an NTFS volume. The following command should show the filesystem type:
    Code:
    sudo blkid -o list

  2. #12
    Join Date
    Feb 2012
    Beans
    396

    Re: Lubuntu - script for "recently used" files

    I took out the
    *
    and it worked fine.
    Now the task is to make a script to print each file with a number in front and to open the one I chose my entering the number.

  3. #13
    Join Date
    Feb 2012
    Beans
    396

    Re: Lubuntu - script for "recently used" files

    yes ext4

  4. #14
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Lubuntu - script for "recently used" files

    Double-click on it and it will be marked! Middle-click and it will be pasted! This is straight-forward and allows you to type the command you want to perform (or open it with).

  5. #15
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Lubuntu - script for "recently used" files

    Would this do the trick?
    Code:
    find -ctime -1 -type f -exec bash -c 'select f;do [[ -n $f ]]&&xdg-open "$f"||exit;done' _ {} +
    Last edited by schragge; March 24th, 2013 at 11:41 PM.

  6. #16
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Lubuntu - script for "recently used" files

    Quote Originally Posted by schragge View Post
    Would this do the trick?
    Code:
    find -ctime -1 -type f -exec bash -c 'select f;do [[ -n $f ]]&&xdg-open "$f"||exit;done' _ '{}' +
    Great script

  7. #17
    Join Date
    Feb 2008
    Location
    In my skin.
    Beans
    Hidden!
    Distro
    Xubuntu

  8. #18
    Join Date
    Feb 2012
    Beans
    396

    Re: Lubuntu - script for "recently used" files

    thanks heaps, it certainly does the trick!!
    Can you tell me how it works from the word "bash" onwards?
    And how can I make it into a file name I can run? When I tried to make it into an alias it gave me an error.

  9. #19
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Lubuntu - script for "recently used" files

    Quote Originally Posted by Kevin McCready View Post
    Can you tell me how it works from the word "bash" onwards?
    1. find's action -exec executes bash -c 'command string' and passes to it the found file names as parameters ( {} is the placeholder for file name and + shows that there're could be many of them on one line)
    2. bash -c 'command string' $0 $1 $2 ... executes everything in the 'command string' as bash script and passes to it all words after that as shell parameters starting from $0.
    3. select is a bash builtin that displays $1, $2, $3 and so on as a menu (I need to specify _ to consume $0 that gets discarded)
    4. f either contains the file name selected from menu or is empty (wrong number/non-number selected).
    5. [[ -n $f ]]&&xdg-open "$f"||exit tests for f: if it's not empty then xdg-open "$f" gets executed, otherwise exit ends the script.
    6. xdg-open opens $f in the user's preferred application for its file type.


    Quote Originally Posted by Kevin McCready View Post
    And how can I make it into a file name I can run? When I tried to make it into an alias it gave me an error.
    Pay attention to proper quoting when making an alias:
    Code:
    alias recent="find -ctime -1 -type f -exec bash -c 'select f;do [[ -n \$f ]]&&xdg-open \"\$f\"||exit;done' _ {} +"
    Last edited by schragge; March 24th, 2013 at 11:41 PM.

  10. #20
    Join Date
    Feb 2012
    Beans
    396

    Re: Lubuntu - script for "recently used" files

    Cool. You've been awesome. Thanks so much!

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •