ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

batch scripting

(1/1)

compn:
i was doing a lot of grepping and it was causing a toll on my hands typing all the extra characters.

so i made a bat file

g.bat:
@echo off
grep -i %1 * | grep -i %2

now i'm wondering if i can make it so i just run it once, and i can just type the grep search words over and over again ?

what i mean is: instead of:
grep -i foo * | grep -i bar
grep -i foo1 * | grep -i bar1
and then, with bat file it looks like this:
g foo bar
g foo1 bar1

i can just do
g.bat
foo bar
(results for foo bar)
foo1 bar1
(results for foo1 bar1)
foo2 bar2
(results for foo2 bar2)

without having to type g each time.


also would be nice to be able to do g foo (it currently errors because the second grep is empty), or g foo bar zed hex whatever number of grep searches i need to do at once.

its been so long i cant remember what this stuff is even called in batch to search how to script it.

rjbull:
i was doing a lot of grepping and it was causing a toll on my hands typing all the extra characters.
[...]
now i'm wondering if i can make it so i just run it once, and i can just type the grep search words over and over again ?
[...]
without having to type g each time.
[...]
its been so long i cant remember what this stuff is even called in batch to search how to script it.
-compn (May 19, 2024, 09:34 PM)
--- End quote ---

There are still a few batch file resources on the web, e.g.


* Rob van der Woude's Scripting Pages
* The Windows Command Line, Batch Files, and Scripting
Don't overlook that even the Windows CMD prompt has line recall and editing.  When you've issued a command, and it's been executed, press Up Arrow to recall it, edit the line if necessary and press Enter to issue the modified command.  Take Command (payware) and its plain text console mode version TCC/LE (freeware) are far better. You get many more features than Microsoft ever dreamt of.  JP Soft seem to have replaced TCC/LE with TCC-RT : Free TCC Runtime for Batch Files, which I haven't tried.  Also, you should probably look at PowerShell, which also I haven't tried.

Navigation

[0] Message Index

Go to full version