Change ? char from files and directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change ? char from files and directory
# 1  
Old 04-01-2015
Change ? char from files and directory

Hello,
I must change files and dirs name which contains che "?" char, I try this:

Code:
rename 's/?/-/' *.*

nothing, what's the problem?
thanks
# 2  
Old 04-01-2015
Did you try to escape the ? ?
# 3  
Old 04-01-2015
In ls, ? sometimes means various kinds of unprintable characters you wouldn't expect to appear in a filename.
# 4  
Old 04-01-2015
Quote:
Originally Posted by RudiC
Did you try to escape the ? ?
yes, but nothing

---------- Post updated at 06:13 PM ---------- Previous update was at 06:12 PM ----------

Quote:
Originally Posted by Corona688
In ls, ? sometimes means various kinds of unprintable characters you wouldn't expect to appear in a filename.

it's seems
# 5  
Old 04-01-2015
In that case, you could try a character class, e.g. print:
Code:
rename 's/[^[:print:]]/-/' *.*

# 6  
Old 04-01-2015
You can also use the inode to refer to the file without having to match its name. Get the number from ls -li, and use it in find:

Code:
$ ls -li

3548035 -rw-r--r-- 1 tyler tyler     52 Oct 20 09:39 a.log

$ find . -xdev -inum 3548035 -exec echo rm '{}' ';'

rm ./a.log

$

Remove the 'echo' once you've tested that it does what you want.
# 7  
Old 04-02-2015
Quote:
Originally Posted by RudiC
In that case, you could try a character class, e.g. print:
Code:
rename 's/[^[:print:]]/-/' *.*

nothing...

---------- Post updated at 09:14 AM ---------- Previous update was at 09:13 AM ----------

Quote:
Originally Posted by Corona688
You can also use the inode to refer to the file without having to match its name. Get the number from ls -li, and use it in find:

Code:
$ ls -li

3548035 -rw-r--r-- 1 tyler tyler     52 Oct 20 09:39 a.log

$ find . -xdev -inum 3548035 -exec echo rm '{}' ';'

rm ./a.log

$

Remove the 'echo' once you've tested that it does what you want.
I need rename all files with ? char... in this case I don't solve my problem...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

2. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

3. Shell Programming and Scripting

Count char, sum and change

Hello, I have some problem in counting char of word, sum and change. I'm not sure shell script can do this. Input data: Sam1 BB BB AA AA BB BB BB Sam2 BB BB AA AA AB AB AB Sam3 BB BB BB AA BB BB BB Sam4 AB AB AB AB AB AB AA Sam5 BB BB AA AA BB BB -- If I count in column 2, B is 9... (3 Replies)
Discussion started by: awil
3 Replies

4. UNIX for Dummies Questions & Answers

How to change database directory to another directory?

Hi, I Installed mysql on my CentOS 6.2 Server. But when I tried to change the location of /var/lib/mysql to another directory. I can't start the mysql. Below is what I've done yum install mysql mysql-server mysql-devel mkdir /path/to/new/ cp -R /var/lib/mysql /path/to/new chown -R... (1 Reply)
Discussion started by: ganitolngyundre
1 Replies

5. Shell Programming and Scripting

Script to change first line of files in directory

I need a script to take the filename of every file in a directory and substitute that file name for whatever is on the first line of the file. There may or may not be anything on the line, but I want the line to be the same as the file name. Most of the script tools I have used are non-destructuve,... (14 Replies)
Discussion started by: LMHmedchem
14 Replies

6. Programming

error: invalid conversion from ‘const char*’ to ‘char*’

Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially): xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’: xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’ The same error with all c++ constructors - gcc 4.4.4. If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies

7. Shell Programming and Scripting

Change a Char Multiple line records

Hi All i have a file that is to big for vi and is a multiple line record 3999||20090127163547796|196.46.162.250|1028|196.207.40.112|2152|00:0C:31:BB:25:5 4|00:00:0C:07:AC:06|655016000575511|05||3C65|0D029C1D|||00644B5A|||||||||||inter... (5 Replies)
Discussion started by: gseptember
5 Replies

8. Shell Programming and Scripting

Change nth Char in a file..

I wanted to Replace if 20th Char is space then Replace by X .. 12345678901234567890 AAAA HEXW PROGRM01 (Ended by 3 Spaces ) Followed by junk(can be spaces als) BBBB HEXW PROGRM01 A0121225001 (Ended by 3 Spaces)Followed by junk I have Tired some thing of this sort ... cat... (4 Replies)
Discussion started by: pbsrinivas
4 Replies

9. Shell Programming and Scripting

Special Char in Multiple Files

We develop a file in windows and move to unix box as a part of deployment. When we do this, we get ctrl-M(^M) character added to the file. So we need to remove ctrl-M(^M) character from all the files from deployment folder and all subfolders folder. Currently we move to individual folders and... (5 Replies)
Discussion started by: thinakarmani
5 Replies

10. UNIX for Dummies Questions & Answers

How do I change ownership of a directory and all of it's files.

How do I change ownership of a directory and all of it's files without changing permissions? (1 Reply)
Discussion started by: mborin
1 Replies
Login or Register to Ask a Question