Search found 93 matches

by berserker
07 Jan 2014 18:52
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Date and Time

Dealing with date and time is more or less a common task when batch scripting. Awk provides simple date and time function for basic time/date manipulation needs. 1) systime() 2) strftime() 3) mktime() 1) systime(). This is the the number of seconds since the system epoch. systime is commonly used to...
by berserker
07 Jan 2014 07:48
Forum: DOS Batch Forum
Topic: Ways to aware that some string contains a substrings
Replies: 24
Views: 20457

Re: Ways to aware that some string contains a substrings

Do you know the better solutions for StartsWith/EndsWith? Do you know the reliable solution for Contains? what you are doing is re-inventing the wheel. like foxi said, the native findstr can do the job of "contains" and starts with, ends with. you can also use tools like grep.exe or awk.e...
by berserker
07 Jan 2014 07:42
Forum: DOS Batch Forum
Topic: Batch to kill (Killer Batch)
Replies: 15
Views: 15600

Re: Batch to kill (Killer Batch)

shashank.kaneria wrote:I am working on a batch script which can kill process who use more than 90% of the CPU.

so you have worked on a batch. Where is it?
by berserker
07 Jan 2014 02:56
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Getting User Input and File Reading

In awk, you can get user input using the getline function eg BEGIN{ print "Enter something" getline entered print "You entered " entered } result C:\>awk -f test.awk Enter something test You entered test here, you the variable "entered" will contain the value of what th...
by berserker
07 Jan 2014 01:03
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Awk User Defined Functions

For this next part of the primer I am going to introduce user defined functions in awk. Awk in fact is a little "programming language" as you can already see what features it has so far. As such, you can create user defined functions inside an awk script. The purpose of functions is to pro...
by berserker
06 Jan 2014 22:03
Forum: DOS Batch Forum
Topic: firefox commandline code for auto-saving webpages
Replies: 7
Views: 10696

Re: firefox commandline code for auto-saving webpages

Maybe put it this way to bars. Since he wants to save the pages as he visits the site then wget had the recursive option to do that. By downloading through wget its the same as he already visited the sites. Although its not clear what he wants to do with the saved pages.
by berserker
06 Jan 2014 21:11
Forum: DOS Batch Forum
Topic: firefox commandline code for auto-saving webpages
Replies: 7
Views: 10696

Re: firefox commandline code for auto-saving webpages

If all you want is just download web page then use wget
by berserker
06 Jan 2014 20:20
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Re: Awk - A nifty little tool for text manipulation and more

If you want to find all records with 2nd column starting with "A", then That should read containing an "A" nice spot. amended. Actually its the ^ that I left out. Next we find how many days are there in the file that has closing price greater than average. This is the code This ...
by berserker
06 Jan 2014 19:27
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 26274

Re: two findstr questions

im more interested in the likeness of wget which is portable, standalone and easy. grep requires other dll. awk is more like php. its better for me to finish studying .bat usefulness to my only window 7-netbook. if i learned enough .bat usage then i will use unix apps so that i can learn their diff...
by berserker
06 Jan 2014 19:17
Forum: DOS Batch Forum
Topic: two findstr questions
Replies: 27
Views: 26274

Re: two findstr questions

Squashman wrote:Not sure if all the versions of grep for windows require the extra dll files.

gnu win32 grep (practically most of them ) has installers so just one click install does the job.
by berserker
06 Jan 2014 18:49
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Writing an awk script - Parsing systeminfo example

Let's say you want to get some information from systeminfo command. eg you want to get the data from these items: OS Name System type System Up Time Original Install Date" Total Physical Memory Available Physical Memory BIOS Version OS Version Here is the code, save as parse_systeminfo.awk BEGI...
by berserker
06 Jan 2014 09:45
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Writing an awk script - Averaging example.

Awk commands are not just for one liners as we have seen so far. You can put awk commands in a script (aka, text file) and have awk run them for you. Its the same as writing a vbscript and having cscript engine runs the command for you. The syntax for running awk scripting is simply (-f option) c:\>...
by berserker
06 Jan 2014 09:12
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Pattern Matching and Substitution

Awk has in built pattern matching and functions for string substitutions. Here I show some basic examples of simple matching and substitution. Regular expressions is a vast topic so if for in depth regex , please consult a regex book. My favorite is Mastering Regular Expression from Oreilly. Pattern...
by berserker
06 Jan 2014 08:40
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Re: Awk - A nifty little tool for text manipulation and more

This code has unbalanced parentheses - and it lacks a command line version. Can that also be implemented? for (x = 0; x <= 10; x++) { if (x == 2) { continue # this continue skips the print statement below } print "something" fixed the parenthesis. Actually you can write it all on the comm...
by berserker
06 Jan 2014 08:30
Forum: DOS Batch Forum
Topic: Awk - A nifty little tool for text manipulation and more.
Replies: 30
Views: 31425

Re: Awk - A nifty little tool for text manipulation and more

awk "BEGIN{a[1]=\"one\" ; a[\"two\"]=2; for(item in a) {print item\" \"a[item] } }" How is the order defined. This prints two 2 before 1 one arrays in awk has no indexing as in normal arrays we see in C. So its arbitrary. I will add this point in. I added a p...