How to search files by wildcard expression
how to search files by wildcard expression,
and list all of them?
for example:
search file as image*.jpg or ima231*.jpg.
please give me some code to study.
thanks in advance.
following code is a filename filter that support '*' and '?', hope it helps.
import java.util.*;
class MyFilenameFilter {
static public void main(String args[]){
byte[] in2=new byte[255];
String filter=null,fileName=null;
try{
while(1>0){
System.out.print("filter (ex: abc*def?.do?):");
in2=new byte[255];
System.in.read(in2);
if((new String(in2)).trim().length()>0) filter=(new String(in2)).trim();
System.out.print("filename (ex: abcerdefi.doc):");
in2=new byte[255];
System.in.read(in2);
if((new String(in2)).trim().length()>0) fileName=(new String(in2)).trim();
System.out.println("filter="+filter+",filename="+fileName+",result="+(chkfn(filter,fileName)? "Matched":"Not Matched"));
} catch(Exception e){
e.printStackTrace();
static boolean chkfn(String chk,String fn) {//ex:chk=*fg?gh fn=tdiekd.exe, or ex:chk=test.csv fn=k.csv
boolean rtn=false;
int x3=0,x4=0,x4Head=0,x4Tail=0;
if(chk.endsWith(".*") && fn.indexOf(".")==-1) chk=chk.substring(0,chk.length()-2);
if(chk.endsWith(".") && fn.indexOf(".")==-1) chk=chk.substring(0,chk.length()-1);
if(fn==null || fn.length()<1) return false;
if(chk==null) return true;
if(chk.length()<1 || chk.equals("*") || chk.equals(".") || chk.equals("*.*")) return true;
int chkLength=chk.length();
int fnLength=fn.length();
int newx4Head=-1,newx4Tail=-1;
int last_asterisk=chk.lastIndexOf("*");
int first_asterisk=chk.indexOf("*");
int asteriskCount=0,aindex[]=new int[20],tmp[]=null,index1=-1,cCount=0;
String cString[]=new String[20];
chk=chk.toUpperCase();
fn=fn.toUpperCase();
char c='0';
boolean found=false;
String chkString="";
//replace each '**' with '*' befroe further action
while(chk.indexOf("**")!=-1){
chk=replace(chk,"**","*");
chkLength=chk.length();
last_asterisk=chk.lastIndexOf("*");
first_asterisk=chk.indexOf("*");
//count the '*' count
x3=0;
while(x3<chkLength){
if(chk.charAt(x3)=='*'){aindex[asteriskCount]=x3; asteriskCount++;}
x3++;
//to get the cString[], each string next to '*'
StringTokenizer st=new StringTokenizer(chk,"*");
while(st.hasMoreElements()){
cString[cCount]=st.nextToken(); cCount++;
//first check the head and the tail
if(first_asterisk>0){//first_asterisk!=-1 && first_asterisk!=0
chkString=chk.substring(0,first_asterisk);
if(chkString.indexOf("?")!=-1){
if(fnLength>first_asterisk-1){
if(cmp(chkString,fn.substring(0,first_asterisk))==false) return false;
} else return false;
} else if(!fn.startsWith(chkString)) return false;
x4Head=chkString.length()+1;
} else if(first_asterisk==0) {
x4Head=findMatch(cString[0],fn);
if(x4Head==-1) return false;
if(last_asterisk!=chkLength-1 && last_asterisk!=-1){
chkString=chk.substring(last_asterisk+1,chkLength);
if(chkString.indexOf("?")!=-1){
if(fnLength-(chkLength-last_asterisk)+1>-1){
if(cmp(chkString,fn.substring(fnLength-(chkLength-last_asterisk)+1,fnLength))==false) return false;
} else return false;
} else if(!fn.endsWith(chkString)) return false;
x4Tail=fnLength-chkString.length();
} else if(last_asterisk==chkLength-1) {
newx4Tail=findMatch(cString[cCount-1],fn.substring(x4Head));
x4Tail=x4Head+newx4Tail+cString[cCount-1].length();
if(asteriskCount>1){
int oldx4Head=x4Head;
if(last_asterisk!=chkLength-1) {
if(cString[cCount-2].indexOf("?")==-1){
x4Tail=fn.substring(x4Head,x4Tail).lastIndexOf(cString[cCount-2]);
if(x4Tail!=-1) x4Tail=x4Tail+cString[cCount-2].length();
if(first_asterisk!=0){
if(cString[1].indexOf("?")==-1){
x4Head=fn.substring(x4Head).indexOf(cString[1]);
if(x4Head!=-1) x4Head=oldx4Head+x4Head;
//before of this, x4head and x4tail are adjusted according to '*', and now it will also adjusted according to '?'
if(x4Head>-1 && x4Tail>x4Head &&
chk.substring(aindex[0]+1,aindex[asteriskCount-1]).indexOf("*")==-1 &&
chk.substring(aindex[0]+1,aindex[asteriskCount-1]).length()!=x4Tail-x4Head &&
chk.substring(aindex[0]+1,aindex[asteriskCount-1]).indexOf("?")!=-1){
newx4Head=-1;
newx4Head=findMatch(chk.substring(aindex[0]+1,aindex[asteriskCount-1]),fn.substring(x4Head,x4Tail));
if(newx4Head>-1) {
x4Head=x4Head+newx4Head;
x4Tail=x4Head+aindex[asteriskCount-1]-(aindex[0]+1);
if(x4Head>-1 && x4Tail>x4Head) return chkfn(chk.substring(aindex[0]+1,aindex[asteriskCount-1]),fn.substring(x4Head,x4Tail));
else return false;
} else if(asteriskCount==0){
if(fnLength==chkLength) return cmp(chk,fn);
else return false;
return true;
static public boolean cmp(String chkString,String fnString){//1.no '*', 2.only for two strings having same length 3.two strings are uppercase before call this method
boolean rtn=false;
int clength=chkString.length(),flength=fnString.length();
if(clength!=flength) return false;
for(int i=0;i<clength;i++){
if(chkString.charAt(i)!='?' && chkString.charAt(i)!=fnString.charAt(i)) return false;
return true;
static public int findMatch(String chkString,String fnString){//to find out the correct index postion for the string between two '*'
int rtn=-1;
boolean found=false;
int chkLength=chkString.length();
int fnLength=fnString.length();
if(chkLength>fnLength) return -1;
for(int i=0;i<fnLength-chkLength+1;i++){
found=true;
for(int j=0;j<chkLength;j++){
if(chkString.charAt(j)!='?' && chkString.charAt(j)!=fnString.charAt(j+i)) {found=false; break;}
if(found) return i;
return rtn;
public static String replace(String s, String s1, String s2) {
if(s!=null && s1!=null && s2!=null){
int i = 0;
int j = s.length();
int k = s1.length();
int l = s2.length();
do {
String s3 = "";
i = s.indexOf(s1, i);
if(i == -1)
break;
StringBuffer stringbuffer = new StringBuffer(s.substring(0, i));
s3 = s.substring(i + k);
stringbuffer.append(s2).append(s3);
s = stringbuffer.toString();
j = s.length();
i += l;
} while(i <= j);
return s;
}
Similar Messages
-
hi,
im a new user in Mac OS. i have a question on how to search By file types in MAC Os.
in Windows you can do a "ind File" by *.mp3....this will search & list all the .mp3 in the HD.
How can i can like this in OSX.
thnxHi, F. C.
There are a couple of approaches to this using Find. Find is implemented in Spotlight but permits more precise search criteria to be specified than using the Spotlight icon.
A. Use Find to search for the extension .mp3:1. In Finder, press the Command-F keyboard shortcut to launch Find.
2. In the top "slice" of the Find window, select the search location, e.g. Computer or Home.
3. Click the Kind pop-up button and select Other...
4. Select Name Extension from the list. If you regularly want to use this as a search criterion, also select the Add to Favorites checkbox.
5. Click OK. Note that the Kind criteria selected in step 3 now shows Name Extension as the criteria.
6. Type mp3 in the text input field next to Name Extension.
Spotlight will return all files whose extension matches mp3. Using the Name Extension criteria is the most precise approach to finding files by their extensions.B. Use Find to search for music files containing mp3:1. In Finder, press the Command-F keyboard shortcut to launch Find.
2. In the top "slice" of the Find window, select the search location, e.g. Computer or Home.
3. Click the Kind pop-up button and select Music.
4. In the Search For field, type mp3.
Spotlight will return all music files that in some way match the search term mp3. This is perhaps the fastest approach, but can be a less precise since it could return some files that contain the character string "mp3" in their name or other metadata attributes but have a different actual extensions, e.g. a file named "MP3 Rocks.aiff".Good luck!
Dr. Smoke
Author: Troubleshooting Mac® OS X -
How to search file in application server using pattern
Hi all,
I want to search file in application server.
Suppose there is file named abc20090808.dat.
Is there is any function module to search the file?
it should return back the file names starting with abc, if the import parameter is abc*
Regards,
Nikhilhello,
Have a look
You can use this function module /SAPDMC/LSM_F4_SERVER_FILE for F4 help for application server file and then you can use the function module TEXT_CONVERT_XLS_TO_SAP to read data into internal table.
access file from application server
regards,
shweta -
How to search files on a windows configured external hard disk on macbook air
I am trying to search files on my passport Ultra Western Digital, which is configured for windows and has read only permissions for my macbook air, i am unable to instant search results through finder or spotlight. Is there a way to search them?
Well, to clarify:
I want to find all user text files and mail messages on a Time Machine backup disk that contain the word "escalator".
By user files I mean those in
/Volumes/Time Machine Backups/Backups.backupdb/<username>iMac/*/Macintosh HD/Users
and subdirectories thereof.
I was trying to use the find command, but it was taking a very long time, so I aborted it. I then realized that most of the files have many hard links, and therefore will be searched many times. That, of course, is a great waste.
Is there some way to search each file only once?
Thanks. -
How to search file contents in finder?
How do I search for file contents in finder? All I see is the option to search "This Mac" or "Edited."
Under the partial results appearing under the search box is a + icon (next to save). To see it, click on the toolbar somewhere so the results popup clears. Then you can define your search.
-
How to search files in the finder in an external NAS disk
If I try to search a file on the NAS disk system does not react although I changed the finder options accordingly
You can check some tools mentioned in this URL : http://www.hongkiat.com/blog/backup-and-sync-tools-for-hard-drives/
Arnav Sharma | http://arnavsharma.net/ Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading
the thread. -
How to search files, get cells, loop, and save
Howdy Folks, I'm another Applescript newbie in over my head. I'm working on a script to copy xl files into a master xl file. the files is a roster with student and class information. the number of students will vary. WIth help from a friend I have it about 80% where I want it. Need help with the rest. I hope its okay to ask multiple question about the script if not i do apoligize.
when the script runs it asks for the location of the file. the files are titled Houston_Sam_DWI_Jan.xlsx. I have several files in a master folder that i am trying to get data from, but the script goes through one at a time.
I know i need to loop it somehow to go through all of the files containing "DWI" in the title, I just don't know how to do it.
the script is set up to get a range of cells, but there are other individual cells i need to copy like dates(C7), Instructor(H7), and location(C11). How do i get these individual cells and paste them to the master doc: Location(E7), Dates (F7), Instructor(G7) and have them repeat down the column as the number of students from each of the classes populates the list.
finally, i have the master file name as annual report, the script does update the anual report file, but when it goes to save it creates a file named "sheet 1". i just want it to update the annual report file and save all changes.
here is the script i am currently working with:
set master_path to alias "Users:bs:Desktop:master:Annual Report.xlsx"
get_all_files(master_path)
on get_all_files(master_path)
set example_path to choose file with prompt "Find an example file to work with"
transfer_data(example_path, master_path)
end get_all_files
on transfer_data(child_path, master_path)
tell application "Microsoft Excel"
set child_book to (open workbook workbook file name (child_path as string))
set child_doc to worksheet 1 of child_book
set master to worksheet 1 of (open workbook workbook file name (master_path as string))
set num to 15 --All lists start at index 12 or later, I'm putting 10 to be safe
set students to {}
tell child_doc --grab values from child document
repeat until (value of cell (("A" & num) as string)) is 1
set num to num + 1
end repeat
repeat until (value of cell (("B" & num) as string)) is ""
set end of students to {name:(value of cell (("B" & num) as string)), driver_id:(value of cell (("C" & num) as string)), DOB:(value of cell (("D" & num) as string)), pre_test:(value of cell (("J" & num) as string)), post_test:(value of cell (("K" & num) as string)), cert_id:(value of cell (("L" & num) as string))}
set num to num + 1
end repeat
end tell
tell master
set num to 7
log (value of cell (("B" & num) as string))
repeat until (value of cell (("B" & num) as string)) is ""
set num to num + 1
end repeat
repeat with student in students
set value of cell (("B" & num) as string) to name of student
set value of cell (("C" & num) as string) to driver_id of student
set value of cell (("D" & num) as string) to DOB of student
set value of cell (("H" & num) as string) to pre_test of student
set value of cell (("I" & num) as string) to post_test of student
set value of cell (("J" & num) as string) to cert_id of student
set num to num + 1
end repeat
save master
end tell
save child_book
close child_book
save active workbook in master_path
close active workbook
end tell
end transfer_data
Any help would be greatly appreciated.That did it. had to tinker with it but it's doing what i want. Thanks for all of the help. here is the final code
tell application "Finder"
set master_path to alias "Users:bs:Desktop:master:Annual Report.xlsx"
set filesWithDWI to get every file of folder ((path to desktop folder) & "master" as string) whose name contains "DWI"
repeat with f in filesWithDWI
my transfer_data(f, master_path)
end repeat
end tell
on processfile(f)
display dialog f as string
end processfile
on transfer_data(child_path, master_path)
tell application "Microsoft Excel"
set child_book to (open workbook workbook file name (child_path as string))
set child_doc to worksheet 1 of child_book
set master to worksheet "sheet 1" of (open workbook workbook file name (master_path as string))
set num to 15 --All lists start at index 12 or later, I'm putting 10 to be safe
set students to {}
tell child_doc --grab values from child document
repeat until (value of cell (("A" & num) as string)) is 1
set num to num + 1
end repeat
repeat until (value of cell (("B" & num) as string)) is ""
set end of students to {namevalue of cell (("B" & num) as string)), driver_idvalue of cell (("C" & num) as string)), DOBvalue of cell (("D" & num) as string)), pre_testvalue of cell (("J" & num) as string)), post_testvalue of cell (("K" & num) as string)), cert_idvalue of cell (("L" & num) as string))}
set num to num + 1
end repeat
set startdate to range "C7"
set classlocation to range "C11"
set instructor to range "H7"
end tell
tell master
set num to 7
log (value of cell (("B" & num) as string))
repeat until (value of cell (("B" & num) as string)) is ""
set num to num + 1
end repeat
repeat with student in students
set value of cell (("B" & num) as string) to name of student
set value of cell (("C" & num) as string) to driver_id of student
set value of cell (("D" & num) as string) to DOB of student
set value of cell (("H" & num) as string) to pre_test of student
set value of cell (("I" & num) as string) to post_test of student
set value of cell (("J" & num) as string) to cert_id of student
set value of cell (("f" & num) as string) to startdate
set value of cell (("E" & num) as string) to classlocation
set value of cell (("G" & num) as string) to instructor
set num to num + 1
end repeat
end tell
save child_book
close child_book
save active workbook in master_path
close active workbook
end tell
end transfer_data -
How to search files on a Time Machine backup disk only once perfile
Greetings,
Goal: I want to find all user files in a set of Time Machine backups residing on a single disk that contain the string "escalator". Now, there are multiple hard links to each file, so a simple search would search each file multiple times. That would take a very long time. Is there a way that I can search (grep) all text files and mail files only once and list those that contain the string? Note that I only want to search user directories; that is,
/Volumes/Time Machine Backups/Backups.backupdb/username’s iMac/Latest/Macintosh HD/Users
where "Latest" can also be any of the dates of all the backups.
Thanks!Well, to clarify:
I want to find all user text files and mail messages on a Time Machine backup disk that contain the word "escalator".
By user files I mean those in
/Volumes/Time Machine Backups/Backups.backupdb/<username>iMac/*/Macintosh HD/Users
and subdirectories thereof.
I was trying to use the find command, but it was taking a very long time, so I aborted it. I then realized that most of the files have many hard links, and therefore will be searched many times. That, of course, is a great waste.
Is there some way to search each file only once?
Thanks. -
How to search file from presentation server
Hi All,
In a ABAP program i want to display a dialog box which will help me to find out any file from presentation server.That dialog box should be display after clicking on parameter on selection screen.Parameter is a simple variable,not a field from any internal table. so i can not use function module F4IF_INT_TABLE_VALUE_REQUEST
Please suggest me any function module which will satisfy my requirement.
Thank you.Hi,
Check this example..
DATA: T_FILETABLE TYPE FILETABLE.
DATA: RC TYPE I.
DATA: USER_ACTION TYPE I.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = T_FILETABLE
rc = RC
USER_ACTION = USER_ACTION
EXCEPTIONS
FILE_OPEN_DIALOG_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Naren -
How to search for files using wildcards * and ?.
Hi All,
I've been searching the forum for a couple of hours now and have been unable to find a good example of how to search a directory (Windows OS) for a file using wildcards * and/or ?. Does anyone out there have a good example that they can share with me?
ThanksHi All,
First of all I want to thank everyone for taking the time to respond to my question. All of your responses where greatly appreciated.
I took the example code that was posted by rkconner, thanks rkconner, and modified it to allow me to search for files in a directory that contain * and/or ?. Yes, I said and/or! Meaning that you can use them both in the same file name, example: r??d*.t* would find readme.txt.
I've posed my complete and thoroughly document code below. I hope it is very helpful to other as I have searched many forums and spent many hours today trying to resolve this problem.
Enjoy
* File Name: WildcardSearch.java
* Date: Jan 9, 2004
* This class will search all files in a directory using the
* asterisk (*) and/or question mark (?) as wildcards which may be
* used together in the same file name. A File [] is returned containing
* an array of all files found that match the wildcard specifications.
* Command line example:
* c:\>java WildcardSearch c:\windows s??t*.ini
* New sWild: s.{1}.{1}t.*.ini
* system.ini
* Command line break down: Java Program = java WildcardSearch
* Search Directory (arg[0]) = C:\Windows
* Files To Search (arg[1]) = s??t*.ini
* Note: Some commands will not work from the command line for arg[1]
* such as *.*, however, this will work if you if it is passed
* within Java (hard coded)
* @author kmportner
import java.io.File;
import java.io.FilenameFilter;
public class WildcardSearch
private static String sWild = "";
* @param args - arg[0] = directory to search, arg[1] = wildcard name
public static void main(String[] args)
String sExtDir = args[0]; // directory to search
sWild = args[1]; // wild card to use - example: s??t*.ini
sWild = replaceWildcards(sWild);
System.out.println("New sWild: " + sWild);
File fileDir = new File(sExtDir);
File[] arrFile = fileDir.listFiles(new FilenameFilter()
public boolean accept(File dir, String name)
return (name.toLowerCase().matches(sWild));
for (int i = 0; i < arrFile.length; ++i)
System.out.println(arrFile.getName());
} // end main
* Checks for * and ? in the wildcard variable and replaces them correct
* pattern characters.
* @param wild - Wildcard name containing * and ?
* @return - String containing modified wildcard name
private static String replaceWildcards(String wild)
StringBuffer buffer = new StringBuffer();
char [] chars = wild.toCharArray();
for (int i = 0; i < chars.length; ++i)
if (chars[i] == '*')
buffer.append(".*");
else if (chars[i] == '?')
buffer.append(".{1}");
else
buffer.append(chars[i]);
return buffer.toString();
} // end replaceWildcards method
} // end class -
How to use glob search with the wildcard in command find?
How to use glob search with the wildcard in command find?
I want to find any file its names begin with "readme" string using command find. Why the following command cannot work?
$find /usr/share/doc -name readme*
However, the following commands can work?
$find /usr/share/doc -name readme\* or
$find /usr/share/doc -name readme'*'
I want to know: After using the “\” or ' ', why the wildcard do not become a character "*"?(still a metacharacter).
Another question:
I want to find any file its names begin with "readme*" string using the command find.What command should I use?I want to know: After using the “\” or ' ', why the
wildcard do not become a character "*"?(still a
metacharacter). The backslash is known as an escape character. It means 'use the character value of the next character, not the special meaning' It is used in a lot of places such as command line, global regular expression patterns, and editors such as vi.
In a typical shell, the splat (*) expands to all file names before passing the file names to the current command. So a \* sequence tells the shell to pass a *, not a list of file names, to the command.
Demo - OpenSuSE Linux 10.3
- I have a bunch of files. Let's list those that end in grid. Create one called *grid, and list again
pops@fuzzyVM:~/pops> ls
a b c startgrid stopgrid
pops@fuzzyVM:~> ls *grid
startgrid stopgrid
pops@fuzzyVM:~> ls \*grid
ls: cannot access *grid: No such file or directory
pops@fuzzyVM:~> touch '*grid'
pops@fuzzyVM:~/pops> ls
a b c *grid startgrid stopgrid
pops@fuzzyVM:~/pops> ls *grid
*grid startgrid stopgrid
pops@fuzzyVM:~/pops> ls \*grid
*grid
pops@fuzzyVM:~/pops>In the above, how would I remove the file *grid, and only that file?
Another question:
I want to find any file its names begin with
"readme*" string using the command find.What command
should I use?What were the results of the two versions you tried? And why? -
How to search to files based on the metadata of the category in CS
Hi,
Can any one tell me how to search the files in the content services based on the metadata of the Category,I know how to search based on the Category using
public static void attributSearch(String searchString)
throws FdkException, RemoteException, Exception
// get the Manager instances
SearchManager sem = s_WsCon.getSearchManager();
CategoryManager cat = s_WsCon.getCategoryManager();
CommonManager cm = s_WsCon.getCommonManager();
FileManager fm = s_WsCon.getFileManager();
Item folder = fm.resolvePath("/idc/workspaces/BoardMembersProject", null);
AttributeRequest[] catAttr =
WsUtility.newAttributeRequestArray("ProjectCategory");
// create AttributeRequest to retrieve CATEGORIES attribute
AttributeRequest[] catClassAttr = WsUtility.newAttributeRequestArray(
Attributes.CATEGORIES, catAttr);
// define search options
NamedValue[] nv = WsUtility.newNamedValueArray(new Object[][] {
{ Options.SEARCH_VERSION_HISTORY, Boolean.TRUE },
{ Options.RETURN_COUNT, new Integer(100)
// get search expresiion
SearchExpression seExp = new SearchExpression();
// searchString ="ProjectCategory";
Item[] item = cat.getRequiredCategories(folder.getId(),catClassAttr);
seExp = new SearchExpression();
NamedValue[] attributes = item[0].getRequestedAttributes();
seExp.setOperator(FdkConstants.OPERATOR_HAS_CATEGORY);
seExp.setRightOperand("["+item[0].getName()+"]");
// search documents
NamedValue[] result = sem.search(seExp, nv, null);
// search result display
for (int i = 0; i < result.length; i++)
if (result.getName().equals(Options.SEARCH_RESULTS))
Item[] resulItem = (Item[]) result[i].getValue();
WsUtility.log("Kveni",resulItem);
if (resulItem != null)
for (int j = 0; j < resulItem.length; j++)
WsUtility.log("File " +resulItem[j].getName());
But how do one search Based on the attributes of the category??
thanks
kveniDownload the PM accelerator kit appropriate to your environment, and check out the TestSearch2.java example.
http://www.oracle.com/technology/products/cs/developer/contentservicesdev/contenservicesdevkit.html
Essentially you need to lookup the internal names of your category attributes, as well as have the internal name of your category class.
categoryClassName = ...; // e.g. AHC_XXX
attribute1name = ....; // e.g. CUSTOM_MYBOOLATTR
you then create a normal search expression such as
String attribute1Operand = "[" + categoryClassName + FdkConstants.SEPARATOR + attribute1name + "]";
SearchExpression expr1 = new SearchExpression();
expr1.setOperator(FdkConstants.OPERATOR_EQUAL);
expr1.setLeftOperand(attribute1Operand);
expr1.setRightOperand(Boolean.TRUE);
Matt. -
Search file for text and delete the found text. How?
I need to know how to search a file for text and delete the found text. I think grep will let you do this but not sure of the syntax.
Hi Dmcrory,
In addition to what Camelot and nobody loopback point out, one must also consider the fact that UNIX text tools are largely line based. You also fail to tell us for what kind of text you are searching. If you are looking for multiple words, there's a very good chance of finding the expression wrapped onto different lines. With hyphenation, even single words can wrap to multiple lines. Tools that search line-by-line will miss these unless you use multiline techniques.
Multiline substitutions require that you write "read-ahead" code for the command line tool that you're using and that you take that into account in the substitution. Given how you want the results to be printed out, you may also want to preserve any newlines found in the match, which is even more difficult. That could bring up the subject of line endings but that's a completely different topic.
I apologize if this sounds discouraging. Multiline searches aren't needed that often and in most of those cases, exceptions can be dealt with by hand. I just didn't want you to get surprised by it. To give you an idea of how easy basic substitution is, have a look at Tom Christiansen's Cultured Perl: One-liners 102 and One-liners 101. Both have some "in-place" substitution examples.
Gary
~~~~
MIT:
The Georgia Tech of the North -
How to search for file in jsp page
i need help on how to search for a file in a folder where there is a lot of subfolder.like how u search in a document in windows. i need a complete codes in jsp page.
thank you in advance.
Message was edited by:
n_dilahno i need to do a search engine in jsp page which is the j2ee.
i type smth than tat file from any folder will appear the same way when u need to search your file in a document in windows.
well can u nice people tell me where i can get the codes bcos i stinks when it come to programming.
thank you very very very much. -
How to search a special string in txt file and return it's position in txt file?
How to search a special string in txt file and return it's position in txt file?
I just posted a solution for a similar question here: http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=362699#M362699
The top portion can search for the location of a string, while the bottom portion is to locate the position of a character. Both can search for a character.
The position of the character within the file is displayed in the indicator(s).
R
Maybe you are looking for
-
Trying to connect iMac to my TV with mini port to hdmi genuine adaptor with no success. Works ok if I connect iMac to works Microsoft laptop, it displays immediately. Then connect Microsoft laptop to TV , absolutely fine. I have looked on Internet &
-
Failing to sync movies: "The disk could not be read from or written to."
Hello, I had approx 10 movie files on my ipad which synced and played fine for the first month I had my ipad. I recently tried to add 3 more movies all in the exact same format as the previous 10, however now I get a message saying that the file coul
-
URGENT : Updating Saudi Payment Output File
Dear Fellow Boarders, We had an urgent requirement to add a new line at the end of "Saudi Payment Output File" I had created the formula for same and attached at the "Organizational Payment Method" Level, via "Further Information" in "Other" Tab. How
-
Dear all, Iam doing my project with database connectivity . the following error is occuring frequently or some time once in 2 or 3 days . Error -2147467259 occured at DB Tools Open Connec (String).vi --> DB Tools Open Connec (Path ).vi -->OQC:vi-->i
-
Forte & web.xml problem
Hi there, I hope what I have is a simple problem to fix. I'm running Forte For Java 4 and developing a web application. When I run a servlet (although it works fine) I am getting a run-time error: ContextConfig[] Configuration error in application we