PRODUCT |
|
|
|
|
|
|
|
|
FAQ |
|
|
|
|
|
|
|
LEARN SCRIPTING |
|
|
|
|
|
|
|
|
|
|
|
SAMPLE SCRIPTS |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HELP / DOCUMENTATION |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Help Page - SS_FindRE
( Some help pages may not display correctly in html because those help pages may have sample code in them, part of which may be mis-interpreted as html tags.
All help pages, including this help page, are available in biterScripting with the help command. )
|
|
Sample Script
SS_FindRE
Purpose
Lists lines in all files matching a pattern in a given directory that contain a specified Regular Expression.
Source Code
#####################################################################
# SCRIPT: SS_FindRE
#
# This script finds instances of a Regular Expression in files whose names match a given
# criterion in a given directory.
#
# The criterion for file names is assigned using FVA (Forward Variable Assignment)
# for str variable $files. The value of $files is of form
# "*.html", "*.js", "*.cpp", "*.h", etc.
#
# The directory name is assigned using FVA
# for str variable $dir. The value of $dir is of form
# "C:/ABC/DEF", ".", etc.
#
# The Regular Expression being sought is assigned using FVA
# for str variable $str. The value of $str is of form
# "class,", "href=", "(cC)opyright", etc.
#
# The start line is assigned using FVA for str variable $from. The
# value is of the form "1", "2", etc. If no value supplied, "1" is assumed.
#
# The end line is assigned using FVA for int variable $to. The
# value is of the form "1", "100", etc. If no value is supplied, "l" (last line) is assumed.
#
# Note that $from and $to are str variables. If you are passing int values, use the makestr() function
# as follows.
# from(makestr(int(1))) to(makestr(int(5)))
#
# This script can be stored and edited as necessary, in a text file
# called SS_FindRE.txt in a directory in your $path. The script can then be called as
#
# script SS_FindRE.txt files("*.cpp") dir("C:/mydir") str("class,") from("1") to("5")
#
#
#####################################################################
# Declare FVA variables.
var str files
var str dir
var str str # The first str is the variable type, the second str is the variable name.
var str from
var str to
# Get the list of files in variable fileList.
var str fileList
script "SS_ListFiles.txt" dir($dir) files($files) > $fileList
# We will store the name of one file in $file.
var str file
# Go thru the $fileList one by one file.
while ($fileList <> "")
do
# Extract the next file.
lex "1" $fileList > $file
# Check if this is a flat file. Directories will
# produce error in the repro command.
af $file > null # We don't want to see the output.
# We only want to set the $ftype variable.
if ($ftype == "f")
do
# Yes, this is a flat file.
echo "File:\t" $file
scr SS_FindLinesRE.txt str($str) file($file) from($from) to($to)
done
endif
done
|
|
© 2008-2013, biterScripting.com. All rights reserved.
biterScripting, biterScript, biterBrowser, biterMobile, biterScripting.com, FVA (Forward Variable Assignment) are trademarks of biterScripting.com. Is it biterScripting-compatible ? is a service mark of biterScripting.com.
Explorer, Unix, Windows are trademarks, service marks or other forms of intellectual property of their respective owners.
|
|