Sponsored Content
Full Discussion: Backslashes in Filenames
Top Forums UNIX for Dummies Questions & Answers Backslashes in Filenames Post 302252401 by shepherdsflock on Wednesday 29th of October 2008 10:47:01 AM
Old 10-29-2008
Yeah.. I tried that. I get critical error. The filenames don't show with the \r so I am certain that is causing some sort of conflict with the filename. I've tried renaming with wildcards. Frustrated.

Thanks for all the suggestions. I do appreciate it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

spaces in filenames

I have a problem with the script below #!/bin/sh for vo in `find -maxdepth 1 -type f -regex "^\./*$"` do ls -l "$vo" some other commands done It works fine until `find ...` returns files with spaces. I've tryed to change IFS but haven't succeed Any solutions? (4 Replies)
Discussion started by: Hitori
4 Replies

2. Shell Programming and Scripting

How to echo 4 backslashes more easy ?

How to echo 4 backslashes more easy ? I can use 16 to echo 4 backslashes. # echo \\ \ # echo \\\\ \ # echo \\\\\\ \\ # echo \\\\\\\\ \\ # echo \\\\\\\\\\ \\\ # echo \\\\\\\\\\\\ \\\ # echo \\\\\\\\\\\\\\ \\\\ (4 Replies)
Discussion started by: sun-guy
4 Replies

3. Shell Programming and Scripting

Trouble with Backslashes

Hi folks, there are windows device names in the sixth column of a comma separated file. A example device name is: \\.\Tape0 I don't get the all string in to a variable, because of the preceding backslash. The first backslash is just cut off and my attempts to manipulate the string afterward... (0 Replies)
Discussion started by: wibo1
0 Replies

4. UNIX for Dummies Questions & Answers

Inserting commas and replacing backslashes with commas

Hi, Newbie here. I have a file that consists of data that I want to convert to a csv file. For example: Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105 Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
Discussion started by: kangaroo
3 Replies

5. Shell Programming and Scripting

Replacing 3 backslashes with 2 in a string

Hi, I have a requirement where i need to replace 3 backslashes with 2 in the below mentioned string, but i am facing problem with backslashes. However i tried the option below but doesnt work. My input remains a constant as i receive it from my upstream. Input String= "-rfile... (3 Replies)
Discussion started by: kk_madrid
3 Replies

6. Shell Programming and Scripting

escaping backslashes to evaluate paths

Hi there, i am struggling with this one, basically i want to replace an existing path string in a file with a new one, but the new one contains slashes which causes problems with "sed", i thought i could change the replacement string into a variable but of course when the variable is evaluated... (4 Replies)
Discussion started by: surfbus78
4 Replies

7. UNIX for Dummies Questions & Answers

printing backslashes

printf "\\" prints a backslash.how we can print multiple backslashes such as "\\\\\\\\\\\\\\\\\\\\". Thanks (4 Replies)
Discussion started by: pandeesh
4 Replies

8. AIX

filemon with no filenames...

i excuted filemon with filemon -u -o /tmp/filemon.out -O all;sleep 60; trcstop. everything is ok, but i only get PID for filenames in Most Active Files. is there any different flags i need to use to get filenames? Code tags please, thanks. (3 Replies)
Discussion started by: curtis911
3 Replies

9. Shell Programming and Scripting

Script to add backslashes to end of certain lines of text

I'd like to write up notes in a relatively readable format and then use a shell script to add LaTeX formatting. Specifically, I'm trying to figure out how to add the LaTeX newline character (\\) to the end of lines without \begin{} or \end{} statements example notes file: \begin{enumerate} --... (2 Replies)
Discussion started by: icskittles
2 Replies

10. Shell Programming and Scripting

Parsing FileNames

Hi, Its been a long time since I've done any shell scripting and I need some help here. Thanks in advance... I need this as a bourne or csh script running under SCO. In a folder I have a list of Backup files named with "TarBackup plus a date and time component suffix" like this; ... (2 Replies)
Discussion started by: stanlyn
2 Replies
ef_expand_file(3)					     Library Functions Manual						 ef_expand_file(3)

NAME
ef_expand_file, del_ExpandFile, ef_last_error, ef_list_expansions, new_ExpandFile - expand filenames containing ~user/$envvar and wildcard expressions SYNOPSIS
#include <libtecla.h> ExpandFile *new_ExpandFile(void); ExpandFile *del_ExpandFile(ExpandFile *ef); FileExpansion *ef_expand_file(ExpandFile *ef, const char *path, int pathlen); int ef_list_expansions(FileExpansion *result, FILE *fp, int term_width); const char *ef_last_error(ExpandFile *ef); DESCRIPTION
The ef_expand_file() function is part of the tecla library (see the libtecla(3) man page). 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 cor- responding environment variable, 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 backslahes that are themselves preceded by backslashes are preserved in the expanded filename. In the presence of wildcards, the returned list of filenames only includes 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 looses 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 doesn't 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 command. 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; } Descriptions of the functions used above are as follows: ExpandFile *new_ExpandFile(void) This 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 filenames that is returned by ef_expand_file(). This array is expanded as needed, so there is no built in limit to the number of files that can be matched. ExpandFile *del_ExpandFile(ExpandFile *ef) This function deletes the resources that were returned by a previous call to new_ExpandFile(). It always returns NULL (ie a deleted object). It does nothing if the ef argument is NULL. 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; FileExpansion *ef_expand_file(ExpandFile *ef, const char *path, int pathlen) The ef_expand_file() function performs filename expansion, as documented at the start of this section. Its first argument is a resource object returned by new_ExpandFile(). A pointer to the start of the filename to be matched is passed via the path argument. This must be a normal NUL terminated string, but unless a length of -1 is passed in pathlen, only the first pathlen characters will be used in the file- name expansion. If the length is specified as -1, the whole of the string will be expanded. The function returns a pointer to a container who's 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 currently exists or not. If there were wildcards, 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 via multiple calls to new_ExpandFile(). On error, NULL is returned, and an explanation of the error can be determined by calling ef_last_error(ef). const char *ef_last_error(ExpandFile *ef) This 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. int ef_list_expansions(FileExpansion *result, FILE *fp, int terminal_width); The ef_list_expansions() function provides a convenient way to list the filename expansions returned by ef_expand_file(). Like the unix ls command, 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
In multi-threaded programs, you should use the libtecla_r.a version of the library. This uses POSIX reentrant functions where available (hence the _r suffix), and disables features that rely on non-reentrant system functions. Currently there are no features disabled in this module. Using the libtecla_r.a version of the library, 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-expansion objects. FILES
libtecla.a - The tecla library libtecla.h - The tecla header file. SEE ALSO
libtecla(3), gl_get_line(3), cpl_complete_word(3), pca_lookup_file(3) AUTHOR
Martin Shepherd (mcs@astro.caltech.edu) ef_expand_file(3)
All times are GMT -4. The time now is 08:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy