Sponsored Content
Full Discussion: Wildcards In UNIX
Top Forums UNIX for Dummies Questions & Answers Wildcards In UNIX Post 13175 by smdakram on Sunday 13th of January 2002 07:09:29 AM
Old 01-13-2002
Data Wildcards In UNIX

on my SCO UNIX wild cards are not displaying wanted result.
Why like that . I think that i was not using proper command .

what are there . how can i use the wildcards in UNIX.
 

10 More Discussions You Might Find Interesting

1. Programming

Makefile wildcards

Using a makefile I want to compile all .c files in the current directory without specifying them directly and then link their associated .o files into a library. How do I do this ? Thanks. (1 Reply)
Discussion started by: rcscott
1 Replies

2. UNIX for Dummies Questions & Answers

ls - wildcards and global use

Hiya, I want to list all files missing a certain pattern and/or filename pattern on the entire drive. In DOS I would type (for instance): dir \t*.doc /s /a which should find all doc files whose filename starts with `t'. How do I do that in a unix shell? Can it be done w/ ls at... (5 Replies)
Discussion started by: ropers
5 Replies

3. UNIX for Dummies Questions & Answers

Wildcards in VI

I'm trying to delete lines from a large text file using VI. Every line that I am wanting to delete start with 'S' - all others do not. (A list of users) I've tried using * but doesn't seem to like it...any ideas... Doesn't have to be VI - but I'm better with VI than sed/awk. (8 Replies)
Discussion started by: peter.herlihy
8 Replies

4. UNIX for Dummies Questions & Answers

wildcards

when writing a shell script (bourne) and using a unix command like 'ls' is there anything special you need to do to use a wildcard (like *)? (3 Replies)
Discussion started by: benu302000
3 Replies

5. UNIX for Dummies Questions & Answers

ls with wildcards

ok, I'm trying to write a script file that lists files with specific elements in the name into a txt file, it looks like this ls s*.dat > file_names.txt can't figure out whats wrong with that line, any ideas? thanks in advance (10 Replies)
Discussion started by: benu302000
10 Replies

6. UNIX for Dummies Questions & Answers

wildcards NOT

Hi All Please excuse another straightforward question. When creating a tar archive from a directory I am attempting to use wildcards to eliminate certain filetypes (otherwise the archive gets too large). So I am looking for something along these lines. tar -cf archive.tar * <minus all *.rst... (5 Replies)
Discussion started by: C3000
5 Replies

7. UNIX for Dummies Questions & Answers

wildcards in path

Is there some rule about using wildcards in path? Say I want to create a file, but one of the directories in the path is called 1433d.default and on different machines it will be called <some other string>.default touch ~/Library/Application/*.default/myfile In theory I thought that... (5 Replies)
Discussion started by: glev2005
5 Replies

8. UNIX for Advanced & Expert Users

Wildcards

These 2 websites do a GREAT job of explaining different types of wildcards. I learned about the categories of characters which I never knew about at all. GNU/Linux Command-Line Tools Guide - Wildcards GREP (1 Reply)
Discussion started by: cokedude
1 Replies

9. Shell Programming and Scripting

Wildcards and exceptions

Hello: I have a very basic question. I'd like to select all files except for one file. For example, say I want to move all of the files in my current directory to a subdirectory called archive, I would use mv ./* archive/ But what if I want to move all files except for README.txt? Is there an... (19 Replies)
Discussion started by: Danny.Boy
19 Replies

10. UNIX for Dummies Questions & Answers

Renaming with wildcards

Hi, I'm new to Unix, but have a directory which has many files in it, well over 1000. The files are called : M07GO.STOPE0001 M07GO.STOPE0002 M07GO.STOPE0003 M07GO.STOPE0004 etc... I would like to rename them to the following : M070001.bin M070002.bin M070003.bin M070004.bin etc....... (4 Replies)
Discussion started by: rnmuk
4 Replies
ef_expand_file(3TECLA)				 Interactive Command-line Input Library Functions			    ef_expand_file(3TECLA)

NAME
ef_expand_file, del_ExpandFile, ef_last_error, ef_list_expansions, new_ExpandFile - expand filename and wildcard expressions SYNOPSIS
cc [ flag... ] file... -ltecla [ library... ] #include <libtecla.h> ExpandFile *ef_expand_file(void); ExpandFile *del_ExpandFile(ExpandFile *ef); FileExpansion *ef_last_error(ExpandFile *ef, const char *path, int pathlen); int ef_list_expansions(FileExpansion *result, FILE *fp, int term_width); const char *new_ExpandFile(ExpandFile *ef); DESCRIPTION
The ef_expand_file() function is part of the libtecla(3LIB) library. It expands a specified filename, converting ~user/ and ~/ expressions at the start of the filename to the corresponding home directories, replacing $envvar with the value of the corresponding environment vari- able, and then, if there are any wildcards, matching these against existing filenames. Backslashes in the input filename are interpreted as escaping any special meanings of the characters that follow them. Only backslashes that are themselves preceded by backslashes are pre- served in the expanded filename. In the presence of wildcards, the returned list of filenames includes only the names of existing files which match the wildcards. Other- wise, the original filename is returned after expansion of tilde and dollar expressions, and the result is not checked against existing files. This mimics the file-globbing behavior of the UNIX tcsh shell. The supported wildcards and their meanings are: * Match any sequence of zero or more characters. ? Match any single character. [chars] Match any single character that appears in chars. If chars contains an expression of the form a-b, then any character between a and b, including a and b, matches. The '-' character loses its special meaning as a range specifier when it appears at the start of the sequence of characters. The ']' character also looses its significance as the terminator of the range expression if it appears immediately after the opening '[', at which point it is treated one of the characters of the range. If you want both '-' and ']' to be part of the range, the '-' should come first and the ']' second. [^chars] The same as [chars] except that it matches any single character that does not appear in chars. Note that wildcards never match the initial dot in filenames that start with '.'. The initial '.' must be explicitly specified in the file- name. This again mimics the globbing behavior of most UNIX shells, and its rational is based in the fact that in UNIX, files with names that start with '.' are usually hidden configuration files, which are not listed by default by the ls(1) command. The new_ExpandFile() function creates the resources used by the ef_expand_file() function. In particular, it maintains the memory that is used to record the array of matching file names that is returned by ef_expand_file(). This array is expanded as needed, so there is no builtin limit to the number of files that can be matched. The del_ExpandFile() function deletes the resources that were returned by a previous call to new_ExpandFile(). It always returns NULL (that is, a deleted object). It does nothing if the ef argument is NULL. The ef_expand_file() function performs filename expansion. Its first argument is a resource object returned by new_ExpandFile(). A pointer to the start of the filename to be matched is passed by the path argument. This must be a normal null-terminated string, but unless a length of -1 is passed in pathlen, only the first pathlen characters will be used in the filename expansion. If the length is specified as -1, the whole of the string will be expanded. A container of the following type is returned by ef_expand_file(). typedef struct { int exists; /* True if the files in files[] exist */ int nfile; /* The number of files in files[] */ char **files; /* An array of 'nfile' filenames. */ } FileExpansion; The ef_expand_file() function returns a pointer to a container whose contents are the results of the expansion. If there were no wildcards in the filename, the nfile member will be 1, and the exists member should be queried if it is important to know if the expanded file cur- rently exists. If there were wild cards, then the contained files[] array will contain the names of the nfile existing files that matched the wild-carded filename, and the exists member will have the value 1. Note that the returned container belongs to the specified ef object, and its contents will change on each call, so if you need to retain the results of more than one call to ef_expand_file(), you should either make a private copy of the returned results, or create multiple file-expansion resource objects with multiple calls to new_Expand- File(). On error, NULL is returned, and an explanation of the error can be determined by calling ef_last_error(ef). The ef_last_error() function returns the message which describes the error that occurred on the last call to ef_expand_file(), for the given (ExpandFile *ef) resource object. The ef_list_expansions() function provides a convenient way to list the filename expansions returned by ef_expand_file(). Like the ls util- ity, it arranges the filenames into equal width columns, each column having the width of the largest file. The number of columns used is thus determined by the length of the longest filename, and the specified terminal width. Beware that filenames that are longer than the specified terminal width are printed without being truncated, so output longer than the specified terminal width can occur. The list is written to the stdio stream specified by the fp argument. Thread Safety It is safe to use the facilities of this module in multiple threads, provided that each thread uses a separately allocated ExpandFile object. In other words, if two threads want to do file expansion, they should each call new_ExpandFile() to allocate their own file-expan- sion objects. EXAMPLES
Example 1: Use of file expansion function. The following is a complete example of how to use the file expansion function. #include <stdio.h> #include <libtecla.h> int main(int argc, char *argv[]) { ExpandFile *ef; /* The expansion resource object */ char *filename; /* The filename being expanded */ FileExpansion *expn; /* The results of the expansion */ int i; ef = new_ExpandFile(); if(!ef) return 1; for(arg = *(argv++); arg; arg = *(argv++)) { if((expn = ef_expand_file(ef, arg, -1)) == NULL) { fprintf(stderr, "Error expanding %s (%s). ", arg, ef_last_error(ef)); } else { printf("%s matches the following files: ", arg); for(i=0; i<expn->nfile; i++) printf(" %s ", expn->files[i]); } } ef = del_ExpandFile(ef); return 0; } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
cpl_complete_word(3TECLA), gl_get_line(3TECLA), libtecla(3LIB), pca_lookup_file(3TECLA), attributes(5) SunOS 5.10 1 Jun 2004 ef_expand_file(3TECLA)
All times are GMT -4. The time now is 10:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy