Aug 19 2006, 12:13 AM
Post
#1
|
|
|
Group: Members Posts: 1,213 Joined: 9-June 05 From: Gobi Desert, Mongolia Member No.: 7,306 |
I have this so far:
CODE for item in dupes[]: mydupeitem=item for item in filter[]: if mydupeitem[2:] = item: pass else write......etc. now is there anything wrong with this? it wipes out my entire bash history, so it never gets to the write statement. filter[] is just a list of filters(strings) and dupes[] is just a list of strings as well, basically i an 'cleaning' my bash history at logoff, I have a remove duplicates script running and it sorts but I would like to remove any "cd blahblah" and rm's mv's etc. any ideas, I am new to python, so any help would be great. |
|
|
|
![]() |
Sep 1 2006, 06:20 PM
Post
#2
|
|
|
Group: Members Posts: 1,213 Joined: 9-June 05 From: Gobi Desert, Mongolia Member No.: 7,306 |
well here is the end result, I think I am getting ahold of it
#!/usr/bin/env python import os import fileinput fileToSearch="/home/zaurus/.bash_history" #filterlist for non-saves, just add as needed filterlist=[ "cd","mv","cp","df","exit"] filteredlist=[] mylist=[] noDupes=[] [mylist.append(line) for line in fileinput.input( fileToSearch )] fileinput.close() [noDupes.append(j) for j in mylist if not noDupes.count(j)] noDupes.sort filteredlist=noDupes os.remove(fileToSearch) fileToOutput = open( fileToSearch, 'w' ) [filteredlist.remove(y) for x in filterlist for y in noDupes if x == y[0:len(x)] ] [fileToOutput.write(item) for item in filteredlist] fileToOutput.close() basically run this under .bash_logout to clean up my bash_history file of duplicates and unwanted commands, eventually I will have it check against "valid" bash commands/executables as well. |
|
|
|
bam Loops And Such Aug 19 2006, 12:13 AM
zmiq2 Instead of
CODEfor item in dupes[]:
... Aug 19 2006, 01:45 PM
bam I agree, I thought "item" was one of the... Aug 19 2006, 05:32 PM
kopsis QUOTE(bam @ Aug 19 2006, 03:13 AM)I have this... Aug 19 2006, 06:14 PM
bam morning,
yea there was some issues, got it all sol... Aug 19 2006, 08:35 PM
kopsis QUOTE(bam @ Aug 19 2006, 11:35 PM)yea there w... Aug 20 2006, 04:10 AM
bam FP is just, phenominal, actually I like it(about h... Aug 20 2006, 08:09 AM![]() ![]() |
|
Lo-Fi Version | Time is now: 19th May 2013 - 04:05 AM |