Re: Great SWT Program



In article <a4448347-5043-4a7b-9dcd-3c9d8437012f@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<twerpinator@xxxxxxxxx> wrote:
On Nov 14, 12:46 pm, blm...@xxxxxxxxxxxxx <blm...@xxxxxxxxxxxxx>
wrote:
I've written myself a little shell script that makes it easy to
start up vim on only the files that contain specified text

That has one obvious problem: you can't launch multiple interactive
apps simultaneously in the same terminal.

Actually maybe you can, with appropriate use of the "screen" utility.
But that's one I have yet to master.

Another place where using a
non-GUI system runs you smack into a severe disadvantage. Unless you
"cheat" and use an xterm while somehow making the script spawn a new
xterm instance for each copy of vi it launches. Without some such
trickery, you'll just get a single vi session open to the first file.
Then when you exit vi will promptly relaunch on the second file, and
so on, as the script blocks until each interactive process it launches
is terminated, then continues. That might be good enough for you,
depending, but if you wanted to flip between several of the files to
compare stuff or whatever you'll have a problem. :)

I sure would, if vi(m) were incapable of editing more than one file.
Fortunately, that's not the case. (I seem to remember that even
"real" vi had this capability, but I might be misremembering.)

If vi supports multiple documents, and launching with multiple files
specified on the command line, you might manage to get a single vi
with all of the files open in it at once IF the paths to all those
files don't collectively exceed the command line length limit for the
shell, whatever THAT is. For a large number of files you'd probably
hit some such limit and either get nothing or a vi session with only
some of the files open.

I don't remember this ever happening. If the collective length of
the file names exceeds the shell's limit, odds are I'm going to
considering some other way of working with the files anyway.

Of course you'd then be stuck with primitive,
awkward, and annoying pre-GUI methods of switching among open
documents...

Yeah. ":n<enter>" to go to the next file.

(I've had occasion to mass-select 80-odd text files and double click
one of them, producing 80 shiny new Notepad windows, and check for a
particular thing in each one before closing it. Easy as pie, and fast
too. Probably a script could be written to do something like that and
just output a list of files that didn't have the trait in question,
but writing and testing and running it would have taken much longer
than just doing what I did. If it had been 80,000 files, though, I'd
obviously have been cracking open the MS-DOS manual and writing a .bat
file. :)

Uh-huh. I'd have to know more about how you did the mass selection
(all the files in a folder, or did they have some common trait
that made it easy to select en masse) and about what you mean by
"didn't have the trait in question" to propose a Unix-y solution.
But unless there's something automation-resistant about which
files are to be selected, I'm pretty sure I could come up with
something no more complicated than what you just mentioned,
and without consulting any reference materials.

There'd still have been the issue of what to do with the
output if it was large enough. Change the script to move or copy the
"interesting" files to some working directory instead of merely
listing them, then go there and work with them after rerunning the
script, I suppose.)

A Unix-y approach would be to use the output of the script (if
it's a list of files) as input/argument to another program.

--
B. L. Massingill
ObDisclaimer: I don't speak for my employers; they return the favor.
.



Relevant Pages

  • Re: "No such file or directory"
    ... The directory containing the script is not your current directory. ... no 'cd' commands in your script, the "current working directory" is the ... typing the 'pwd' command) from which you run the script. ... put a 'pwd' in your script just before lockUpload.sh is ...
    (comp.unix.programmer)
  • Re: -bash: /usr/local/bin/relaxer: Permission denied
    ... it's a script that launches a java routine ... but it won't run from the command line unless you TELL it to. ...
    (comp.os.linux.setup)
  • Re: Why my bash script does not work inside cron?
    ... there is a source command to source ba2. ... tobash, it behaves differently when invoked as sh. ... modify your script to comply with sh syntax (e.g. no function names ... it works on _are_ in the current working directory. ...
    (comp.unix.shell)
  • Re: mex-files and previously c-written code
    ... you can run your simulator exe from your m script, and send the results to a text file and then read it in your script. ... will be written to the program working directory (not the MATLAB ... wrote a file but to my surprise the MATLAB engine could not read it. ... calling engEvalString with a cd command to change the directory. ...
    (comp.soft-sys.matlab)
  • Re: Great SWT Program
    ... xterm instance for each copy of vi it launches. ... as the script blocks until each interactive process it launches ... If vi supports multiple documents, ... obviously have been cracking open the MS-DOS manual and writing a .bat ...
    (comp.lang.java.programmer)

Loading