Change ? char from files and directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change ? char from files and directory
# 8  
Old 04-02-2015
Show us the output from the command:
Code:
ls -1

(note that the option is the digit one; not the lowercase letter ell). And highlight the ? characters you are trying to replace. And, also show us the output from the command:
Code:
"ls" -1|od -bc

so we can see the characters that are being printed as question marks by ls when output is directed to a terminal. (The quotes around the ls are to avoid any aliases that might be in place.)
# 9  
Old 04-08-2015
Quote:
Originally Posted by Don Cragun
Show us the output from the command:
Code:
ls -1

(note that the option is the digit one; not the lowercase letter ell). And highlight the ? characters you are trying to replace. And, also show us the output from the command:
Code:
"ls" -1|od -bc

so we can see the characters that are being printed as question marks by ls when output is directed to a terminal. (The quotes around the ls are to avoid any aliases that might be in place.)
the first command:

Code:
Ricorso Edilpi? Dobbiaco.doc
Ricorso Edilpi?-Quadraccia.doc

second:

Code:
0000000 122 151 143 157 162 163 157 040 105 144 151 154 160 151 227 040
          R   i   c   o   r   s   o       E   d   i   l   p   i 227
0000020 104 157 142 142 151 141 143 157 056 144 157 143 012 122 151 143
          D   o   b   b   i   a   c   o   .   d   o   c  \n   R   i   c
0000040 157 162 163 157 040 105 144 151 154 160 151 227 055 121 165 141
          o   r   s   o       E   d   i   l   p   i 227   -   Q   u   a
0000060 144 162 141 143 143 151 141 056 144 157 143 012
          d   r   a   c   c   i   a   .   d   o   c  \n
0000074

# 10  
Old 04-08-2015
Try this:

Code:
mv file  $(ls file | tr -d '\227')

# 11  
Old 04-08-2015
Quote:
Originally Posted by protocomm
Try this:

Code:
mv file  $(ls file | tr -d '\227')


this is the result:

Code:
 for i in * ; do mv "$i"  $(ls "$i" | tr -d '\227'); done
mv: target 'Dobbiaco.doc' is not a directory
mv: target 'Edilpi-Quadraccia.doc' is not a directory

# 12  
Old 04-08-2015
Quote:
Originally Posted by ionral
this is the result:

Code:
 for i in * ; do mv "$i"  $(ls "$i" | tr -d '\227'); done
mv: target 'Dobbiaco.doc' is not a directory
mv: target 'Edilpi-Quadraccia.doc' is not a directory

try this:

Code:
 for i in *;do mv "$i"  "$(echo "$i" | tr -d '\227')";done

# 13  
Old 04-08-2015
Quote:
Originally Posted by protocomm
try this:

Code:
 for i in *;do mv "$i"  "$(echo "$i" | tr -d '\227')";done

yes! it's ok now!
now I must this in recursive mode, I've more directory and sub
advice?
thanks
# 14  
Old 04-08-2015
test this:

Code:
find . -type f -name "*.doc" | while read -r i;do mv "$i"  "$(echo "$i" | tr -d '\227')";done

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