The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - Newcomers (http://hintsforums.macworld.com/forumdisplay.php?f=15)
-   -   removing selected files (http://hintsforums.macworld.com/showthread.php?t=105043)

roparzhhemon 09-05-2009 09:11 AM

removing selected files
 
Hello all,

I should like to know if there's a purely Bash solution to
this scripting problem (I know how to solve it using an OCaml-created
executable, but that's heavy somehow...)


Given a directory, erase the PDF files in it coming from a TEX or LATEX file
(in other words, erase only the files whose names ends in .pdf,
and erase xyz.pdf only when xyz.tex exists in the directory).

Ewan

honestpuck 09-05-2009 09:14 PM

Code:

#!/bin/bash

for i in *.PDF
do
        base=`basename -s txt $i`
        dname="${base}tex"

        if [ -f dname ] ; then
                rm $i
        fi
done

Not fully tested and will probably break if your file names have spaces.

// Tony

roparzhhemon 09-06-2009 02:43 AM

This works, except that
Code:

basename -s txt
should be
Code:

basename -s tex
and
Code:

*.PDF
should be
Code:

*.pdf
By the way, to include the treatement of filenames ending with an uppercase PDF,
with what should I replace "for i in *.PDF" ?
Does "for i in *.pdf *.PDF" work ?

Ewan


Quote:

Originally Posted by honestpuck (Post 550959)
Code:

#!/bin/bash

for i in *.PDF
do
        base=`basename -s txt $i`
        dname="${base}tex"

        if [ -f dname ] ; then
                rm $i
        fi
done

Not fully tested and will probably break if your file names have spaces.

// Tony


honestpuck 09-06-2009 03:31 AM

Actually Ewan, it should be 'basename -s pdf' - I forgot that line when I was translating from another script.

I also got the test wrong - it should be [ -a $dname ]

Covering both PDF and pdf is harder - this should do it.

Code:

#!/bin/bash

for i in *.pdf *.PDF
do
        b=`basename -s pdf $i`
        base=`basename -s PDF $b
        dname="${base}doc"
        echo $dname

        if [ -a $dname ] ; then
                echo $i
        fi
done

Not enough time to test totally but it does appear to work. Once again, spaces in filenames will ruin it.

// Tony

Hal Itosis 09-06-2009 05:56 PM

Quote:

Originally Posted by honestpuck (Post 550986)
I also got the test wrong - it should be [ -a $dname ]

No... -a is used as an "and" to join 2 *tests* together -- so -a with one only arg is almost meaningless (perhaps equivalent to -e?).
The -f you had before was just fine.


Quote:

Originally Posted by honestpuck (Post 550986)
for i in *.pdf *.PDF

Wrong again. First, either .pdf or .PDF alone is enough to get the shell to match all cases. (Try it... the filename behavior in OSX is case insensitive: ls ~/*EsKtOp will list Desktop items). Second, having both .pdf and .PDF as args to the for statement actually creates a problem... because it matches everything twice, and so the script ends up trying to do more than necessary. [e.g., when run with echo or ls it prints every match twice.]


Quote:

Originally Posted by honestpuck (Post 550986)
base=`basename -s PDF $b

Missing the trailing backtick` there. (seems to me, both your scripts were *fully* untested).


Quote:

Originally Posted by honestpuck (Post 550986)
dname="${base}doc"

Don't need the quotes there. dname=${base}doc will do just fine. [doc?]

The trick is to quote the "$dname" variable when it gets used. Note: the dname variable from your first post (after if [ -f) was missing the $ prefix to make it a variable. So if [ -f dname ] would always fail (unless some file named "dname" was present).

Quote:

Originally Posted by honestpuck (Post 550986)
Once again, spaces in filenames will ruin it.

All that's needed is quotes in the proper place.

--

If case doesn't matter (i.e., only lowercase .pdf files will exist), then this is good enough:

x=.pdf y=.tex; for i in *$x; do [[ -f `basename -s $x "$i"`$y ]] && ls "$i"; done

[i used the x and y variables to make the script more easily adaptable.]


If both .pdf and .PDF items need handling, then more syntax is required:

xa=.pdf xb=.PDF y=.tex; for i in *$xa; do
[[ -f `basename -s $xa "$i"`$y ||
-f `basename -s $xb "$i"`$y ]] && ls "$i"; done

Note: oddball 'mixed-case' instances (like .Pdf) will go undetected.

Naturally, change the ls command to rm once you're satisfied it works. I'm fairly certain it won't trip over any spaces in filenames. But, i didn't test for all potential filename gotchas (such as quotes, slashes and various other hazardous punctuation).

-HI-

honestpuck 09-06-2009 07:03 PM

No, I tested it quickly. It was a conversion from a script I used for something similar and the cut and paste wasn't perfect - my version has the closing backtick.

I was actually thinking after I posted that I had it backwards - if the case of the .tex files is always correct then the smart way would be to loop through those and then just change the rm to 'rm "${base}[Pp][Dd][Ff]"' and cover all the cases.

There is s good case for basename -s having a case insensitive option <g>.

// Tony

Hal Itosis 09-06-2009 11:43 PM

Quote:

Originally Posted by honestpuck (Post 551095)
if the case of the .tex files is always correct then the smart way would be to loop through those and then just change the rm to 'rm "${base}[Pp][Dd][Ff]"' and cover all the cases.

Fortunately, the case of the .tex files is of no consequence... as once again, the shell is making that call (or rather the OS is i guess):
Code:

$ mkdir testd; cd testd; touch test.tEx; ls
test.tEx
$ [ -f *.TeX ] && echo yes || echo no
yes

Your rm "${base}[Pp][Dd][Ff]" idea is great. I like that.

[Though, hopefully that extreme is never needed... i prefer the flexibility of those x and y variables, for simple script alteration. Then again, if it's always gonna be pdf files... sure, why not.]


Quote:

Originally Posted by honestpuck (Post 551095)
There is s good case for basename -s having a case insensitive option <g>.

Agreed! :)

roparzhhemon 09-07-2009 03:41 PM

Actually, it seems your solution is not working Hal : when I tried it on my
files, I got error messages indicating that the basename command was used
with an incorrect syntax (although I can't figure out why).

Is there a special reason you use a && instead of a "if" construct (which
seemed more natural to me in this case?)

Ewan

EatsWithFingers 09-07-2009 04:57 PM

Quote:

Originally Posted by honestpuck (Post 551095)
I was actually thinking after I posted that I had it backwards - if the case of the .tex files is always correct then the smart way would be to loop through those and then just change the rm to 'rm "${base}[Pp][Dd][Ff]"' and cover all the cases.

The following code loops through each .tex file and removes the corresponding .pdf file if it exists:

(EDIT: only works with .tex and .pdf -- i.e. not .PdF .Tex etc)
(EDIT 2: updated code at end)

Code:

for i in *.tex ; do
  if [ -f "${i%.tex}.pdf" ] ; then
    rm "${i%.tex}.pdf" ;
  fi ;
done

In fact, you can remove the 2nd and 4th lines and it'll still have the desired effect. The only difference being that you'll get a "rm: <FILE_NAME>.pdf: No such file or directory" warning for each .tex file that doesn't have a corresponding .pdf.


EDIT 2: the following code works for *.TeX, *.PDf, etc:

Code:

for i in *.[tT][eE][xX] ; do
  if [ -f "${i%.*}".pdf ] ; then
    rm "${i%.*}".pdf ;
  fi ;
done

NOTE: the deletion works because rm <FILE_NAME>.pdf will remove <FILE_NAME>.pDf and so on. But this only works when .pdf is outside the quotes. Similarly for the file test.

Hal Itosis 09-07-2009 11:07 PM

Quote:

Originally Posted by roparzhhemon (Post 551224)
Actually, it seems your solution is not working Hal : when I tried it on my files, I got error messages indicating that the basename command was used
with an incorrect syntax (although I can't figure out why).

Show me (copy/paste) the entire Terminal session, *including* the command used (and perhaps a listing of the working directory too).
BTW, what Mac OS and Bash versions are you running?


Quote:

Originally Posted by roparzhhemon (Post 551224)
Is there a special reason you use a && instead of a "if" construct (which seemed more natural to me in this case?)

For a simple if/then (single stage), i much prefer the list construct. That's what feels "natural" to me. When things get deeper (nested if/thens), then i revert to what is easier.

honestpuck 09-07-2009 11:57 PM

Quote:

For a simple if/then (single stage), i much prefer the list construct. That's what feels "natural" to me. When things get deeper (nested if/thens), then i revert to what is easier.
I, OTOH, started out life as a C programmer (you should see my Python code - I frequently forget and loop over something rather than use a map function) so I prefer if/thens. :D

// Tony

roparzhhemon 09-08-2009 07:07 AM

Quote:

Originally Posted by Hal Itosis (Post 551296)
Show me (copy/paste) the entire Terminal session, *including* the command used (and perhaps a listing of the working directory too).


Apologies Hal, your solution did work but a character slipped in my copy/paste
and I didn't notice ...

The use of "%" in FingerEater's solution is terser and better (I think) than invoking
the basename command. I had never read about this use of "%" in Bash before. Is there
a site where it is explained in more detail (not the Bash manual ...) ?

For the record, below is the script I finally wrote to get rid of some files produced
by pdflatex, not only in the current directory but also in any subdirectory :

Code:

for ff in `find . -name *.tex`;
do
    replaced="${ff%.tex}.pdf";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.aux";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.log";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.dvi";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
done


Hal Itosis 09-08-2009 11:24 AM

Quote:

Originally Posted by roparzhhemon (Post 551380)
The use of "%" in FingerEater's solution is terser and better (I think) than invoking the basename command. I had never read about this use of "%" in Bash before. Is there a site where it is explained in more detail (not the Bash manual ...) ?

Try pasting this url in Safari and see if you have this file:
file:///usr/share/doc/bash/bashref.html#SEC30

Else, google for "Shell Parameter Expansion".

Hal Itosis 09-08-2009 11:54 AM

Quote:

Originally Posted by EatsWithFingers (Post 551236)
EDIT 2: the following code works for *.TeX, *.PDf, etc:

for i in *.[tT][eE][xX]

That does work. But (as i mentioned above in post #5) this will also match *all* cases:

for i in *.tex


Quote:

Originally Posted by EatsWithFingers (Post 551236)
In fact, you can remove the 2nd and 4th lines and it'll still have the desired effect. The only difference being that you'll get a "rm: <FILE_NAME>.pdf: No such file or directory" warning for each .tex file that doesn't have a corresponding .pdf.

I'm not getting any warnings here.
From what i can see, this works perfectly (even with weird 'mixed-case' files):

for i in *.tex; do ls "${i%.*}".[Pp][Dd][Ff]; done

Does that **not** work for someone? (Show me listing and session).

Gotta admit, i considered a shell parameter expansion solution at first... but i was unable to put it together so cleverly, the way you did. Ironically, roparzhhemon likes it (and so do i) because it's "terser and better". So... what happened to "natural" then? :D

Hal Itosis 09-08-2009 12:12 PM

Quote:

Originally Posted by roparzhhemon (Post 551380)
For the record, below is the script I finally wrote to get rid of some files produced
by pdflatex, not only in the current directory but also in any subdirectory :

Code:

for ff in `find . -name *.tex`;
do
    replaced="${ff%.tex}.pdf";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.aux";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.log";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
    replaced="${ff%.tex}.dvi";
    if [ -f $replaced ]; then
        rm $replaced;
        echo "File $replaced deleted"
    fi;
done


I suppose you know this already, but i'll say it anyway:
while that script does find tex files everywhere in the hierarchy...
the only pdf, aux, log, and dvi files it's looking at (for comparison purposes)
are in the top level of the current working directory.

EatsWithFingers 09-08-2009 02:31 PM

Quote:

Originally Posted by Hal Itosis (Post 551416)
I'm not getting any warnings here.

On my system (OS X 10.5.8, Bash 3.2), I get:

Code:

Test $> echo $BASH_VERSION
3.2.17(1)-release
Test $> ls
1.pdf                4.PDF
1.tex                4.b.teX
2.tex                5 and a half.teX
3.TEx                5 and a half.PdF
3.pdf                6.TEX
Test $> rm 2.pdf
rm: 2.pdf: No such file or directory
Test $>

However, "rm 4.pdf" will delete the file "4.PDF".


Quote:

Originally Posted by Hal Itosis (Post 551416)
From what i can see, this works perfectly (even with weird 'mixed-case' files):

for i in *.tex; do ls "${i%.*}".[Pp][Dd][Ff]; done

Does that **not** work for someone? (Show me listing and session).

I get the following:

Code:

Test $> ls
1.pdf                4.PDF
1.tex                4.b.teX
2.tex                5 and a half.teX
3.TEx                5 and a half.PdF
3.pdf                6.TEX
Test $> for i in *.tex; do ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf
ls: 2.[Pp][Dd][Ff]: No such file or directory
Test $>

So *.tex is not matching 3.TEx, 4.b.teX, 5 and a half.teX, or 6.TEX.


But, (a modified version of) the code I gave produces:

Code:

Test $> ls
1.pdf                4.PDF
1.tex                4.b.teX
2.tex                5 and a half.teX
3.TEx                5 and a half.PdF
3.pdf                6.TEX
Test $> for i in *.[tT][eE][xX] ; do if [ -f "${i%.*}".pdf ] ; then ls "${i%.*}".pdf ; fi ; done
1.pdf
3.pdf
5 and a half.pdf
Test $>

and a further edited version produces:

Code:

Test $> ls
1.pdf                4.PDF
1.tex                4.b.teX
2.tex                5 and a half.teX
3.TEx                5 and a half.PdF
3.pdf                6.TEX
Test $> for i in *.[tT][eE][xX] ; do ls "${i%.*}".pdf ; done
1.pdf
ls: 2.pdf: No such file or directory
3.pdf
ls: 4.b.pdf: No such file or directory
5 and a half.pdf
ls: 6.pdf: No such file or directory
Test $>


Hal Itosis 09-08-2009 02:52 PM

Quote:

Originally Posted by EatsWithFingers (Post 551452)
Code:

Test $> echo $BASH_VERSION
3.2.17(1)-release
Test $> ls
1.pdf                4.PDF
1.tex                4.b.teX
2.tex                5 and a half.teX
3.TEx                5 and a half.PdF
3.pdf                6.TEX
Test $> rm 2.pdf
rm: 2.pdf: No such file or directory
Test $>


Ah, i see my mistake now (no extra tex file, duh)... thanks.
You were right.

I'm liking this now:

for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done

Strictly speaking, the final [Pp][Dd][Ff] isn't needed (pdf will do).
But, it's nice to see it list the file using the exact case of the file.

EatsWithFingers 09-08-2009 03:08 PM

Quote:

Originally Posted by Hal Itosis (Post 551459)
I'm liking this now:

for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done

Strictly speaking, the final [Pp][Dd][Ff] isn't needed (pdf will do).
But, it's nice to see it list the file using the exact case of the file.

That still doesn't work. You need to replace i in *.tex with i in *.[Tt][Ee][Xx]. And then ${i%.[Tt][Ee][Xx]} can be replaced by ${i%.*}. Using the same set of files as in my previous post:

Code:

Test $> for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".[Pp][Dd][Ff] ] && ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf
Test $> for i in *.[Tt][Ee][Xx]; do [ -f "${i%.*}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf
3.pdf
5 and a half.PdF
Test $>

EDIT: As pointed out below, the first bit should in fact read:

Code:

Test $> for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf
Test $>


Hal Itosis 09-08-2009 04:30 PM

Quote:

Originally Posted by EatsWithFingers (Post 551462)
That still doesn't work.

Works just fine here (using *your* recent file list).
Is your disk formatted as a case-sensitive filesystem perhaps?

Very few people do that.


Quote:

Originally Posted by EatsWithFingers (Post 551462)
You need to replace i in *.tex with i in *.[Tt][Ee][Xx].

As already discussed, that's not needed (see post #5):
Code:

$ for i in *.[Tt][Ee][Xx]; do echo "$i"; done
1.tex
2.tex
3.TEx
4.b.teX
5 and a half.teX
6.TEX

$ for i in *.tex; do echo "$i"; done
1.tex
2.tex
3.TEx
4.b.teX
5 and a half.teX
6.TEX

Makes absolutely zero difference (but adds 9 unnecessary chars).
If your Mac can't reproduce that output, then your filesystem must be case sensitive.


Quote:

Originally Posted by EatsWithFingers (Post 551462)
Code:

Test $> for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".[Pp][Dd][Ff] ] && ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf


Whoa, what is that stuff in red? I never posted that.

EatsWithFingers 09-08-2009 05:34 PM

Quote:

Originally Posted by Hal Itosis (Post 551474)
Works just fine here (using *your* recent file list).
Is your disk formatted as a case-sensitive filesystem perhaps?

Very few people do that.

[..]

If your Mac can't reproduce that output, then your filesystem must be case sensitive.

I get a different output in the second case. Only 1.tex and 2.tex are printed. In fact, just doing "ls *.tex" only outputs 1.tex and 2.tex. My machine (a G4 PowerBook, circa March 2004) was originally a Panther system and was upgraded to Leopard via an "Archive & Install". I've never reformatted my HD at all, so it's not something I have done willingly (I don't recall being given that option when upgrading to Leopard). I can't seem to find the info in Disk Utility or System Profiler - do you know where it would be shown? (EDIT: found it, see below) Of course, it would appear that my file-system is indeed case sensitive.

Quote:

Originally Posted by Hal Itosis (Post 551474)
Whoa, what is that stuff in red? I never posted that.

Oops, sorry. Looks like I copied and pasted the wrong thing in my history. However, what you posted gives the same output as was indicated (on my seemingly case-sensitive system). I've updated my previous post accordingly.


EDIT: Output from diskutil in Terminal

Code:

$> diskutil info /
  Device Identifier:        disk0s9
  Device Node:              /dev/disk0s9
  Part Of Whole:            disk0
  Device / Media Name:      Untitled

  Volume Name:              Macintosh HD
  Mount Point:              /
  File System:              Journaled HFS+
                            Journal size 8192 KB at offset 0x69db000
  Owners:                  Enabled

  Partition Type:          Apple_HFS
  Bootable:                Is bootable
  Media Type:              Generic
  Protocol:                ATA
  SMART Status:            Verified
  Volume UUID:              <POSSIBLY SENSITIVE HEX-LIKE STRING>

  Total Size:              74.5 Gi (80018485248 B) (156286104 512-byte blocks)
  Free Space:              15.7 Gi (16807895040 B) (32827920 512-byte blocks)

  Read Only:                No
  Ejectable:                No
  Whole:                    No
  Internal:                Yes
$>

Oddly, there is no mention of "case-sensitive" in the file-system type... (this post says there should be)

EDIT: Upon further reading, the bash shell seems to be case-sensitive, but can be told to be case-insensitive. Hal, you don't happen to have the 'nocaseglob' option set, do you? (e.g. in your .bashrc or .bashprofile files)

If I set that option, I get the output you get:

Code:

Test $> shopt -s nocaseglob
Test $> ls *.tex
1.tex                        3.TEx                        5 and a half.teX
2.tex                        4.b.teX                6.TEX
Test $>


Hal Itosis 09-08-2009 06:24 PM

Hmm, you know what? At this point, an extra 9 chars which make a script work for both case-sensitive and case-insensitive filesystems? Fine, it's worth it. Let's not discuss it any further.

:) [kidding]

Quote:

Originally Posted by EatsWithFingers (Post 551490)
My machine (a G4 PowerBook, circa March 2004) was originally a Panther system and was upgraded to Leopard via an "Archive & Install". I've never reformatted my HD at all, so it's not something I have done willingly (I don't recall being given that option when upgrading to Leopard).

Yeah, it's not an option. We have to plan and prepare for it ourselves (backup everything and -- when booted from the system DVD -- use the Disk Utility there to erase the HD, just before installing the new OS). Only those folks who want to go through all that procedure even bother. I like to do it for major system upgrades, e.g., Tiger to Leopard. I figure the Disk Utility in 10.5.0 knows what's best for OS 10.5.0 -- better than Disk Utility in Tiger or (egads) Panther anyway. A clean install on a virgin disk. Ahh, no worries.

--

Do you use Adobe Products? (Creative Suite, etc.)
I've read they bug-out on case sensitive filesystems.
Then again, it's not 100% clear that's what you have.
[Maybe start a new thread for this... i'm not sure.]

EatsWithFingers 09-08-2009 06:33 PM

Quote:

Originally Posted by Hal Itosis (Post 551500)
Do you use Adobe Products? (Creative Suite, etc.)
I've read they bug-out on case sensitive filesystems.
Then again, it's not 100% clear that's what you have.
[Maybe start a new thread for this... i'm not sure.]

Nope, no Adobe software.

Did you see my (many) edits in the last post? I definitely don't have a case-sensitive system, but passing the 'nocaseglob' option to bash gets me the behaviour you have (i.e. bash is case-sensitive by default). Looks like 'nocaseglob' could be key...

Hal Itosis 09-08-2009 06:41 PM

Quote:

Originally Posted by EatsWithFingers (Post 551490)
EDIT: Upon further reading, the bash shell seems to be case-sensitive, but can be told to be case-insensitive.
Hal, you don't happen to have the 'nocaseglob' option set, do you? (e.g. in your .bashrc or .bashprofile files)

If I set that option, I get the output you get:

Code:

Test $> shopt -s nocaseglob
Test $> ls *.tex
1.tex                        3.TEx                5 and a half.teX
2.tex                        4.b.teX                6.TEX
Test $>


Guilty...
Code:

$ shopt |grep glob
dotglob                off
extglob                off
failglob              off
nocaseglob            on
nullglob              off

$ grep glob ~/.b*
/Users/halito/.bashrc:shopt -s nocaseglob

$ shopt -u nocaseglob

$ for i in *.tex; do [ -f "${i%.[Tt][Ee][Xx]}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done
1.pdf


<sigh>
i hate unix. :D

--

You're right, this one's more universal:

for i in *.[Tt][Ee][Xx]; do [ -f "${i%.*}".pdf ] && ls "${i%.*}".[Pp][Dd][Ff]; done

[now i have to find that thread at ars technica where i got mislead last spring... it's probably locked. ;-) ]

EatsWithFingers 09-08-2009 06:55 PM

Quote:

Originally Posted by Hal Itosis (Post 551503)
Guilty...

Hey, at least the tangent which we took this thread on has come to a (satisfying?) end. You had me worried about my system for a while there...! :p

Quote:

Originally Posted by Hal Itosis (Post 551503)
<sigh> i hate unix. :D

It's like the universe: probably makes a lot of sense if you know all the rules governing it! (Unfortunately, no one does...)

ganbustein 09-08-2009 10:27 PM

Quote:

Originally Posted by Hal Itosis (Post 551503)
Guilty...
Code:

$ grep glob ~/.b*
/Users/halito/.bashrc:shopt -s nocaseglob


If you're going to do that, you might as well also do:

Code:

bind 'set completion-ignore-case'
(and why do I think you probably already have?).

The trick is to remember that you've done it.
Unix ought to have a "list all my customizations" command. Hmm... that shouldn't be too hard. Write a script to capture all settable options to a file:

alias -p
bind -pvs
enable -p
shopt -p
set

Generate the same file from a virgin install, and keep it around. (Such a file could be part of a virgin install. Or log in as Guest and run the script.)
Use diff to find all the ways you're different.
You'd probably also want to have a list of ignorable differences (like the value of $USER or $HOME).

No... I will resist. (Another reason to hate unix -- it sucks you in by making everything seem so doable.)

Hal Itosis 09-08-2009 11:12 PM

Quote:

Originally Posted by ganbustein (Post 551548)
If you're going to do that, you might as well also do:
Code:

bind 'set completion-ignore-case'
(and why do I think you probably already have?).

Yes, but for some reason i have...
bind 'set completion-ignore-case on'

Not sure if that trailing "on" is redundant or what. [?]
Can't remember where i dug that up. [i'd like to find a good tutorial on bind.]


Quote:

Originally Posted by ganbustein (Post 551548)
The trick is to remember that you've done it.

Now he tells me. :o

ganbustein 09-09-2009 12:19 AM

Quote:

Originally Posted by Hal Itosis (Post 551557)
Yes, but for some reason i have...
bind 'set completion-ignore-case on'

Not sure if that trailing "on" is redundant or what. [?]

From info readline (which oddly is more complete under Tiger than Leopard, probably because manually installing ruby gave me a later version),

Quote:

Except where noted, readline variables can take the values On or Off
(without regard to case). Unrecognized variable names are ignored.
When a variable value is read, empty or null values, "on" (case-insen-
sitive), and "1" are equivalent to On. All other values are equivalent
to Off.
I'm glad you're back from vacation. Things have been dull without you.


All times are GMT -5. The time now is 10:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.