Sponsored Content
Top Forums UNIX for Advanced & Expert Users File name contains escape character--how to fix? Post 302993857 by drysdalk on Wednesday 15th of March 2017 12:07:18 PM
Old 03-15-2017
Hi,

The inode thing is exactly what I've always done in this situtation. But I just thought I'd have a play about and see if I could find another answer, and there's this approach too (which might be handier if you need to script this on a regular basis, for some really weird reason).

On up-to-date Bash on modern Linux, you can use a regex like this:

[^[:print:]]

to match non-printable characters only. I created a file with the same name as yours, and some other besides, and here's a sample session showing that regex in action.

Code:
$ ls -lb
total 0
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:03 Right
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 15:58 Wrong\033[D\033[D\033[D\033[D\033[DRight
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:02 Wrong\ Filename.csv
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:03 Wrongness
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:02 Wrong.txt
$ ls Wrong[^[:print:]]*
Wrong?[D?[D?[D?[D?[DRight
$ rm -v Wrong[^[:print:]]*
removed 'Wrong'$'\033''[D'$'\033''[D'$'\033''[D'$'\033''[D'$'\033''[DRight'
$ ls -l
total 0
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:03 Right
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:02 Wrong Filename.csv
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:03 Wrongness
-rw-rw-r-- 1 unixforum unixforum 0 Mar 15 16:02 Wrong.txt
$

So if you absolutely needed to automate the removal of such things, this might be a useful approach if your shell and/or distro support it.
This User Gave Thanks to drysdalk For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Escape character in vi?

I want to replace a string which contains "/" in vi but what is the escape character for forward slash? e.g. I have a text file with the contents below and I want to replace "/Top/Sub/Sub1" with "ABC". /Top/Sub/Sub1 The replace command I am using is ... (4 Replies)
Discussion started by: stevefox
4 Replies

2. Shell Programming and Scripting

awk / escape character

Hi I'm trying to split a dir listing eg /home/foo1/foo2 I'm using ksh I've tried dir=/home/foo1/foo2 splitit=`echo $dir | awk -F '\/' '{print $1}'` echo $splitit nothing is output! I have checked the escape character. The only one I have found is \ BTW `pwd` | awk -F \/... (8 Replies)
Discussion started by: OFFSIHR
8 Replies

3. Shell Programming and Scripting

Escape character

Hi , I want to change space to ' in my script. I tried doing this, sed 's/ /\'/g' filename but i could not get it. can some one help me please. Thanks, Deepak (4 Replies)
Discussion started by: deepakpv
4 Replies

4. Shell Programming and Scripting

escape character in tcsh

Hello, I wanted to display command with echo like this in tcsh. output should be "//'test.test1.test2'" (" at both ends also required in output) Please help me. (1 Reply)
Discussion started by: balareddy
1 Replies

5. Shell Programming and Scripting

Escape character - sed

Hi All, How do i write in sed for the 6th and 7th field of etc/passwd file as it involves "/" character? Does mine below is correct? It's incomplete script as i need help with syntax as i always getting may errors :( Example of etc/passwd file: blah:x:1055:600:blah... (6 Replies)
Discussion started by: c00kie88
6 Replies

6. Shell Programming and Scripting

awk escape character

ll|awk '{print "INSERT INTO SCHEMA.TABLE_NAME VALUES (`"$9 "`,"$5");" }' INSERT INTO SCHEMA.TABLE_NAME VALUES (``,); INSERT INTO SCHEMA.TABLE_NAME VALUES (`TABLE_PARTITION_Y2010M03D06.dmp`,7923328); INSERT INTO SCHEMA.TABLE_NAME VALUES (`TABLE_PARTITION_Y2010M03D06.log`,1389); But I want ' in... (2 Replies)
Discussion started by: faruque.ahmed
2 Replies

7. Shell Programming and Scripting

replace \ (escape character)

All , i have input line as below . abc\ , ewioweioi \, and want the output as below removing the "\" abc , ewioweioi , could anyone help me out (2 Replies)
Discussion started by: expert
2 Replies

8. Shell Programming and Scripting

sed - with escape character

i have string as below str=".<date>" in which i need to replace < with /< , when i tried with sed , got the output. --> echo $str | sed 's/</\\</g' .\<date> when i tried to assign it to a variable , i am not getting the same --> a=`echo $str | sed 's/</\\</g'` ; echo $a... (4 Replies)
Discussion started by: expert
4 Replies

9. Shell Programming and Scripting

ksh escape a character

friends, I have a situation where i am using a $RANDOM function along with the filename, I want this to be escaped by the OS in the first assignment (works as expected) and executed in the second assignment (does not execute $RANDOM) filename1=filename1_\$RANDOM echo $filename1... (3 Replies)
Discussion started by: Balaji M
3 Replies

10. Shell Programming and Scripting

Function to add escape character before specified character

Hi , I am looking for a function which will do the following. 1. I have a variable which will hold few special chracter like SPECIAL_CHARS="& ;"2. I have an escape character. ESCAPE_CHAR="\"3. Now when I passed some string in the function it will return the same string but now it will... (8 Replies)
Discussion started by: Anupam_Halder
8 Replies
named-checkconf(1M)					  System Administration Commands				       named-checkconf(1M)

NAME
named-checkconf - named configuration file syntax checking tool SYNOPSIS
named-checkconf [-v] [-t directory] filename DESCRIPTION
The named-checkconf utility checks the syntax, but not the semantics, of a named configuration file. OPTIONS
The following options are supported: -t directory Change the root directory to directory so that include directives in the configuration file are processed as if run by a named configuration whose root directory has been similarly changed. -v Print the version of the named-checkconf program and exit. OPERANDS
The following operands are supported: filename The name of the configuration file to be checked. If not specified, it defaults to /etc/named.conf. EXIT STATUS
0 No errors were detected. 1 An error was detected. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWbind9 | |Interface Stability |External | +-----------------------------+-----------------------------+ SEE ALSO
named(1M), named.conf(4), attributes(5) BIND 9 Administrator Reference Manual NOTES
Source for BIND9 is available in the SUNWbind9S package. SunOS 5.10 15 Dec 2004 named-checkconf(1M)
All times are GMT -4. The time now is 09:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy