Help to Develop a LINUX macro?

Hi Experts,

i would like to get your help to do some development to the below linux commands which i run under .cmd file in windows

@echo off
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999901"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999914"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999955"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999956"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999902"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999936"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999938"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999927"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999954"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999980"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999981"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999903"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999904"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999923"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999977"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999978"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999911"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999979"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "NULL"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe -v "96478029999"|f:\linuxutils\grep.exe -v "NULL"|f:\linuxutils\wc.exe -l
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\wc.exe -l
echo -------------------------------------------------------------------------------------

the result for the above is just numbers for the counts it does, i want to:

1- add a string before the number, like x value
2- I want the out put to be directed to one single txt to excel file which is better for me, as i prefer excel for reporting

Thanks in advance.

Are you going to continue to use Windows?
Or are you switching to Linux?

If you must keep using Windows, I thoroughly recommend you install and use the Cygwin environment. It comes with the bash shell and is very Linux-like, yet you are still running Windows and all your Windows applications still work exactly as before. (I currently have to use Windows at work and I would die without Cygwin!)

But if you don't want to install Cygwin, I recommend you at least install and use MinGW/MSYS. It's a lighter weight, similar Linux-like environment that also comes with a bash shell, but has less utilities.

But if even that's too much, there is zsh, a bash-like shell that you can use instead of the awful Windows CMD shell.

If you absolutely MUST use the awful CMD shell, you could at least put your "f:\linuxutils" directory in your Windows PATH variable so you don't have to specify it each time.

See, with bash (or even a simple sh shell), you can do something like this inside a loop, with a different value for $NUMBER each time. Note that '.*' is a wildcard that matches any number of any characters.

COUNT="$(grep 'T11.*,9647800.*'$NUMBER  dump3.txt | wc -l)"

Hi,

thanks you very much for your reply, actually i can't install any of your tools because it is not my PC and related to customer; the only allowed is the linux utilities application which runs under windows.

for me, i use windows and i have the cygwin which works perfectly.

but here, my problem is not the loop or the application; i just need to arrange the results into a txt or xls file and to put a word before each output in the same line; could you please suggest such solution for me?

thanks.

 

echo "1" >> otuput.tt
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999901"|f:\linuxutils\wc.exe -l >> otuput.tt
echo "2" >> otuput.tt
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999914"|f:\linuxutils\wc.exe -l >> otuput.tt
echo "3" >> otuput.tt
call f:\linuxutils\grep.exe "T11" f:\blocked_ranges\dump3.txt|f:\linuxutils\grep.exe ",9647800"|f:\linuxutils\grep.exe "9647802999955"|f:\linuxutils\wc.exe -l >> otuput.tt

why dont you try egrep ? (you can give multiple pattern)
Native Win32 ports of some GNU utilities

try the below commands

 
f:\linuxutils\grep.exe "T11.*,9647800.*9647802999901"  f:\blocked_ranges\dump3.txt
f:\linuxutils\grep.exe -c "T11.*,9647800.*9647802999901"  f:\blocked_ranges\dump3.txt |f:\linuxutils\wc.exe -l