SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#26 2015-09-14 21:54:45

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: Aliases/Functions thread

Offline

Help fund CrunchBang, donate to the project!

#27 2015-09-14 21:59:59

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: Aliases/Functions thread

Offline

#28 2015-09-17 07:39:06

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 4,148
Website

Re: Aliases/Functions thread

if TEST
then
    THIS
else
    THAT
fi

Offline

#29 2015-09-17 07:44:25

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 4,148
Website

Re: Aliases/Functions thread

Most of my aliases just run scripts, but these two functions are occasionally useful:

newest ()  {
    [[ $1 ]] || return 1
    local i
    candidate="$1";
    for i in "$@";
    do
        [[ -f $i ]] || continue
        [[ $i -nt $candidate ]] && candidate="$i"
    done
    echo "$candidate"
}

oldest ()  {
    [[ $1 ]] || return 1
    local i
    candidate="$1"
    for i in "$@"
    do
        [[ -f $i ]] || continue
        [[ $i -ot $candidate ]] && candidate="$i"
    done
    echo "$candidate"
}

Just pass them a list of files, like 'newest ./*'

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo