topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 11:59 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: batch scripting  (Read 2725 times)

compn

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 54
    • View Profile
    • Donate to Member
batch scripting
« on: May 19, 2024, 09:34 PM »
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

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: batch scripting
« Reply #1 on: May 20, 2024, 05:26 PM »
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.

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


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.