Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
dateien auflistung
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
pieter_parker
Veteran
Veteran


Joined: 07 Aug 2006
Posts: 1488
Location: 127.0.0.1

PostPosted: Sun Oct 12, 2008 11:58 am    Post subject: dateien auflistung Reply with quote

nnnnnnnn__nn__name
davon hab ich ein paar dutzend dateien (n = zahl)
nach den ersten 8 zahlen sind sie automatisch sortiert, wie aber kann ich sie mir in der console nach "name" sortiert auflisten lassen ?
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Sun Oct 12, 2008 12:26 pm    Post subject: Reply with quote

Eine Methode, die nur "ls" benutzt, kenne ich nicht. Hier eine Perl-Lösung, die bloß die sortierten Dateinamen des aktuellen Verzeichnisses ausspuckt.
Code:
perl -e 'print map {$_->[0], "\n"} sort {$a->[1] cmp $b->[1]} map {[$_, substr $_, 14]} <*>'

_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
l3u
Advocate
Advocate


Joined: 26 Jan 2005
Posts: 2616
Location: Konradsreuth (Germany)

PostPosted: Sun Oct 12, 2008 12:46 pm    Post subject: Reply with quote

Meiner ist kürzer :-D
Code:
ls -1 | sort -k 5 -t "_"

Und ohne Perl.
Back to top
View user's profile Send private message
papahuhn
l33t
l33t


Joined: 06 Sep 2004
Posts: 626

PostPosted: Sun Oct 12, 2008 12:53 pm    Post subject: Reply with quote

Ah, cool. Bei sort hab ich auch gesucht, aber war wohl nicht aufmerksam genug.
_________________
Death by snoo-snoo!
Back to top
View user's profile Send private message
pieter_parker
Veteran
Veteran


Joined: 07 Aug 2006
Posts: 1488
Location: 127.0.0.1

PostPosted: Sun Oct 12, 2008 1:16 pm    Post subject: Reply with quote

entweder hab ich mich falsch ausgedrueckt, oder bei mir im system stimmt etwas nicht oder die beiden befehle tun nicht das was sie sollen

z.b. 2 dateien die heissen
20080125__05__bbb
20080229__10__aaa

ich moechte sie aber so angezeigt bekommen
aaa
bbb

ohne 20080125__05__ und ohne 20080229__10__ und nach nach buchstaben sortiert
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sun Oct 12, 2008 1:37 pm    Post subject: Reply with quote

dann mußt du die Ausgabe noch entsprechend nachbearbeiten; um bei Libbys Beispiel zu bleiben: ls -1 | sort -k 5 -t "_" | sed 's/.*_\(.*\)$/\1/'
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Finswimmer
Bodhisattva
Bodhisattva


Joined: 02 Sep 2004
Posts: 5467
Location: Langen (Hessen), Germany

PostPosted: Sun Oct 12, 2008 1:39 pm    Post subject: Reply with quote

Wenn du sie aber nur als aaa und bbb angezeigt bekommen willst, woher weisst du dann, welche Dateien das vorher waren?
Bringt doch nix, oder?

$echo "20080125__05__bbb
20080229__10__aaa "|gawk -F "__" {'print $3'}|sort

liefert:
aaa
bbb

Moved from Deutsches Forum (German) to Diskussionsforum.
_________________
Bitte auf Rechtschreibung, korrekte Formatierung und Höflichkeit achten!
Danke
Back to top
View user's profile Send private message
Anarcho
Advocate
Advocate


Joined: 06 Jun 2004
Posts: 2970
Location: Germany

PostPosted: Mon Oct 13, 2008 10:51 am    Post subject: Reply with quote

Think4UrS11 wrote:
dann mußt du die Ausgabe noch entsprechend nachbearbeiten; um bei Libbys Beispiel zu bleiben: ls -1 | sort -k 5 -t "_" | sed 's/.*_\(.*\)$/\1/'


Ist wohl auch ein wenig Overkill. Wenn dann doch bitte erst abscheiden, dann ist auch das Sortieren einfacher!

Es sollte auch

Code:
ls -1 | cut -d"_" -f5 |sort


(Ungetestet da gerade nicht an einem Linux-PC)
_________________
...it's only Rock'n'Roll, but I like it!
Back to top
View user's profile Send private message
pieter_parker
Veteran
Veteran


Joined: 07 Aug 2006
Posts: 1488
Location: 127.0.0.1

PostPosted: Mon Oct 13, 2008 8:11 pm    Post subject: Reply with quote

irgendwie macht das nciht so richtig sinn mit der auflistung, hab die dateien kopiert, und umbenannt, tut
Back to top
View user's profile Send private message
Finswimmer
Bodhisattva
Bodhisattva


Joined: 02 Sep 2004
Posts: 5467
Location: Langen (Hessen), Germany

PostPosted: Mon Oct 13, 2008 8:52 pm    Post subject: Reply with quote

pieter_parker wrote:
irgendwie macht das nciht so richtig sinn mit der auflistung, hab die dateien kopiert, und umbenannt, tut


Hö? Ganze Sätze wären hilfreich.

Tobi
_________________
Bitte auf Rechtschreibung, korrekte Formatierung und Höflichkeit achten!
Danke
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum