File name starts with esc character.

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers File name starts with esc character.
# 1  
Old 10-26-2016
File name starts with esc character.

How can I refer to a file named esc[G ? I need to delete it or move it.

TIA
# 2  
Old 10-26-2016
cd to the folder it's in, get its inode number with ls -li, then

Code:
find . -inum inodenumber -exec echo rm '{}' ';'

Remove the 'echo' once you've tested it and are sure it does what you want.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 10-26-2016
Would
Code:
mv -i *G

or
Code:
rm -i *G

help? Apply utmost care when answering the confirmation question!
This User Gave Thanks to RudiC For This Post:
# 4  
Old 10-26-2016
Quote:
Originally Posted by RudiC
Would
Code:
mv -i *G

or
Code:
rm -i *G

help? Apply utmost care when answering the confirmation question!
There are ways to directly enter escape characters into shell commands, but the method varies depending on what shell you're using, command history editing mode, etc.; but the following should work on any system using an ASCII based codeset:
Code:
mv  $(printf '\033[G') whatever

or:
Code:
rm  $(printf '\033[G')

as long as you're using a shell that understands POSIX standard command substitutions.
These 2 Users Gave Thanks to Don Cragun For This Post:
# 5  
Old 10-26-2016
Corona, I'll have to remember that "inode" technique. After making sure there was only one file in the directory ending in G, the mv command changed the same to something standard like Rudic and Don suggested.
I had to take a hex dump of the ls -l to see its true name.
# 6  
Old 10-26-2016
In this case, another way that work under Linux bash and I think work fine under sh,ksh,...
In fact, depend terminal configuration (often touch CTRL-V), we can check:
Code:
$ stty -a
speed 38400 baud; rows 42; columns 158; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

Here, in red, lnext show ^V (CTRL-V), so, you can write the name of file by typing:
'CTRL-V' and 'ESCAPE' and '[' and 'G' keys.

Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Seperated a Column from 'ESC' Character seperated file

Hi Experts I have an escape seperated fields in the unix file. And in the below format file I need to extract the first column. Please help its urgent. cat -v op.dat | head 24397028^ I want to extract the file in below format ( with only first column ) 24397028 2439707 thanks. ... (6 Replies)
Discussion started by: neha_suri06
6 Replies

2. Shell Programming and Scripting

Insert content of file before the first occurrence of a line starts with a pattern in another file

Hi all, I'm new to scripting.. facing some problems while inserting content of a file into another file... I want to insert content of a file (file2) into file1, before first occurrence of "line starts with pattern" in file1 file1 ====== working on linux its unix world working on... (14 Replies)
Discussion started by: Jagadeesh Kumar
14 Replies

3. Shell Programming and Scripting

Need to write a shell script that starts one, then kills it, then starts another?

This is on a CentOS box, I have two scripts that need to run in order. I want to write a shell script that calls the first script, lets it run and then terminates it after a certain number of hours (that I specify of course), and then calls the second script (they can't run simultaneously) which... (3 Replies)
Discussion started by: btramer
3 Replies

4. UNIX for Advanced & Expert Users

Script to rename file that was generated today and which starts with date

hello, can someone please suggest a script to rename a file that was generated today and filename that being generated daily starts with date, its a xml file. here is example. # find . -type f -mtime -1 ./20130529_4995733057260357019.xml # this finename should be renamed to this format.... (6 Replies)
Discussion started by: bobby320
6 Replies

5. Shell Programming and Scripting

ESC[70G[ and ^M characters in text file

Hi, I have a text file which when I do a 'cat' on it looks like below with the OK’s showing in green and any FAIL showing in red. cat filename output: ===== MySQL Query Check ===== DB mpuser is alive. 733 = Expected 733 Tables. OK ] DB mpuser_wf is alive. 61 =... (6 Replies)
Discussion started by: bunti
6 Replies

6. Shell Programming and Scripting

Execution problem ---to remove the lines which starts with one type of character

Hi, I have one file, I need to check if file exist or not and then remove the lines which starts with ? My file1.out data is some thing abcabcppp xyzxyzpqr ????????? ????????? Output should be in test.out abcabcppp xyzxyzpqr I am getting the output as below but the File does not exist... (4 Replies)
Discussion started by: Ramyajiguru1
4 Replies

7. Shell Programming and Scripting

How to copy lines that starts with either 3 or 4 into new file?

Hi Guys, I have an awk script that would search the input file for line that starts with a number 3 and copies into a new text file. I want to extend this script to find the lines that either starts with 3 or a or b and copy all those lines into the new file. Here is what I have so far:... (1 Reply)
Discussion started by: Amith821
1 Replies

8. Shell Programming and Scripting

how to delete lines from a file which starts with a specific pattern

I need to delete those lines from a file, which starts with 45. How to do it? (3 Replies)
Discussion started by: mady135
3 Replies

9. Shell Programming and Scripting

Deleting all characters from 350th character to 450th character from the log file

Hi All, I have a big log file i want to delete all characters (between 350th to 450th characters) starting at 350th character position to 450th character position. please advice or sample code. (6 Replies)
Discussion started by: rajeshorpu
6 Replies

10. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies
Login or Register to Ask a Question