Help to Develop a LINUX macro?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help to Develop a LINUX macro?
# 1  
Old 07-19-2011
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.
# 2  
Old 07-19-2011
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.
Code:
COUNT="$(grep 'T11.*,9647800.*'$NUMBER  dump3.txt | wc -l)"

# 3  
Old 07-20-2011
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.
# 4  
Old 07-20-2011
Code:
 

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

Code:
 
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

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Guide me in the right direction to develop application for UNIX/Linux

Hi all, Am good in C & C++, i just joined as a fresher in a French IT company. In my own interest and love towards Linux and open source. i want to develop as much as applications for linux. i got the basic training on linux commands, and currently am working really hard to gain more... (11 Replies)
Discussion started by: mr_ganapathy
11 Replies

2. Shell Programming and Scripting

I would like to have some exercises to develop my skills

Hi , I would like to do some exercises/scripts in order to develop my skills in shell scripts, can someone pass me some links/suggestions where i can find this? Thanks a lot :) (3 Replies)
Discussion started by: prpkrk
3 Replies

3. Programming

Linux Kernel code "current" macro

I was going through the Linux code, i stuck with few inline assembly language code, I have tried online but in vain. Any help is much appreciated. Thanks. /* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) { struct... (3 Replies)
Discussion started by: kumaran_5555
3 Replies

4. Programming

Please help me to develop algorithm

Hi guys , in my study book from which I re-learn C is task to generate all possible characters combination from numbers entered by the user. I know this algorithm must use combinatorics to calculate all permutations. Problem is how to implement algortihm. // This program reads the four numbers... (0 Replies)
Discussion started by: solaris_user
0 Replies

5. UNIX for Dummies Questions & Answers

Help to develop a new application

Hi all, I am a beginner in advanced unix and just i finished my course in that so now I want to develop an application using advanced unix concepts and middleware technology, so that i can gain an initial working knowledge. Kindly give me a suggestion of what i can develop. (5 Replies)
Discussion started by: jimmyuk
5 Replies

6. Programming

Make-question - redefine a macro, using another macro..?

I think there is no problem to use any macro in a new macro definishion, but I have a problem with that. I can not understand why? I have a *.mak file that inludes file with many definitions and rules. ############################################## include dstndflt.mak ... One of the... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. UNIX for Dummies Questions & Answers

unix develop environment

hi! i am Carlos i study @ UABC (Autonomy University of Baja California)... i have a final project.... i need to make a presentation of the new... unix develop environment... but... i have some problems with that.... could you tell me something to help me? (0 Replies)
Discussion started by: Nx GT-R
0 Replies

8. Shell Programming and Scripting

develop a new kernel

Hi people, I am trying to install a second kernel on my Red Hat 8.0 machine. the existing kernel is 2.4.18 and I am trying to have 2.4.20. I already downloaded the source extracted it run make , make dep and make bzImage . Now when trying to copy the installed kernel image from /usr/src to... (4 Replies)
Discussion started by: bashirpopal
4 Replies
Login or Register to Ask a Question