I just found out how to delete such files witch special characters:
cd <directory with that file>
ls -ali
At the very left of the directory listing you see the ID of the inode of each file.
Delete your file via inode ID:
find . -inum <inode ID of your file> -exec rm -i {} \;
This worked fine for my issue. Hope this helps!
It works on Ubuntu systems which has nautilus
as a default file-manager.
Run the below command on terminal to see the recently accessed(aka viewed) files.
sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel
Information about all the recently accessed files are stored in this particular ~/.local/share/recently-used.xbel
file. Extracting only the file along with it's path was done by the above command.
Command Explanation:
sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel
-n
--> suppress automatic printing of pattern space
-r
--> Extended regex. If we use sed with -r
, then we don't have to escape some characters like ((
,)
,{
,}
,etc)
's/.*href="([^"]*)".*/\1/p'
--> sed searches for a line which has this(.*href="([^"]*)".*
) regex in the input file. If it find any, then it grabs only the characters that are within double quotes which was after href=
(href=""
) and stored it in a group. Only the stored group are printed through back-reference(\1
).
Example:
$ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel
file:///media/truecrypt8/bar.txt
file:///media/truecrypt8/picture.txt
file:///media/truecrypt8/bob.txt
file:///media/truecrypt8/movie.txt
file:///media/truecrypt8/music.txt
file:///media/truecrypt8/foo.txt
If you want the output to be formatted then run this,
$ sed -nr 's/.*href="([^"]*)".*/\1/p' ~/.local/share/recently-used.xbel | sed 's|\/\/| |g'
file: /media/truecrypt8/bar.txt
file: /media/truecrypt8/picture.txt
file: /media/truecrypt8/bob.txt
file: /media/truecrypt8/movie.txt
file: /media/truecrypt8/music.txt
file: /media/truecrypt8/foo.txt
Best Answer
easily use the expansion"*":
This what is called filename expansion which use some special characters called wildcards.
suppose you have a directory containing the files (file, file0, file1, file01)
Some know wildcards:
The question mark (?) is a special character that causes the shell to generate filenames. It matches any single character in the name of an existing file.
example:
The shell expands the "file?" argument and generates a list of files in the working directory that have names composed of "file" followed by any single character.
Then the output would be file0 and file1
The asterisk (*) performs a function similar to that of the question mark but matches any number of characters, including zero characters, in a filename.
now the output of the command:
would be file, file0, file1 and also file01
The [ ] Special Characters causes the shell to match filenames containing the individual characters within the brackets.
for example the output of the command:
would be:
file0 file1 file01
This is just a simple introduction for shell expansion, you can read more :