LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-23-2013, 08:46 PM   #1
andrew777
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Rep: Reputation: 0
How can I find all files ending with a \r


Hello,

I have some files that were accidentally created with a \r at the end of the name because of a transfer from Windows to Linux.

Example:
file1.html\r

Can someone tell me what the syntax of a recursive list command would be to find all files that have a \r as the last character.

Thank you
 
Old 09-23-2013, 09:46 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,580
Blog Entries: 2

Rep: Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037Reputation: 4037
Code:
ls -R *\\r
If you use Zsh instead of Bash
Code:
echo **/*\\r
should also work.
 
Old 09-24-2013, 06:47 AM   #3
andrew777
LQ Newbie
 
Registered: Feb 2009
Posts: 14

Original Poster
Rep: Reputation: 0
It did not work for me...

$ ls -R *\\r
/bin/ls: cannot access *\\r: No such file or directory
$ ls -R \*\\r
/bin/ls: cannot access *\\r: No such file or directory
 
Old 09-24-2013, 07:29 AM   #4
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 3,956

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
this worx for me:
Code:
[schneidz@hyper cobra]$ ll /home/schneidz/music
total 21452
-rw-rw-r--. 1 schneidz schneidz 17747542 Jun 22 14:26 08-k.i._-_machal_montano-single_forever.flac
drwxr-xr-x. 2 schneidz schneidz     4096 Feb 11  2013 midnight-marauders
drwxr-xr-x. 2 schneidz schneidz     4096 Feb 11  2013 perceptionists-black-dialogue
-rw-rw-r--. 1 schneidz schneidz  4207742 Jun 22 14:29 sf.mp3
-rw-rw-r--. 1 schneidz schneidz        0 Sep 24 08:27 test\r
[schneidz@hyper cobra]$ ll /home/schneidz/music/*'\r'
-rw-rw-r--. 1 schneidz schneidz 0 Sep 24 08:27 /home/schneidz/music/test\r
 
Old 09-24-2013, 08:00 AM   #5
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,451

Rep: Reputation: 439Reputation: 439Reputation: 439Reputation: 439Reputation: 439
Not sure these tests are working correctly
Actually not so easy to create

Code:
for i in {01..20};do echo -e Test${i}.txt\\r;done | while read line;do touch $line;done
mv them around a little now find them with find

Code:
find . -name "*^M"
NOTE:
^M is special.. to get it Ctrl+v ( release ) <enter>


I assume you would like to fix these

Code:
find -name "*^M" | while read File;do mv -v "${File}" "${File%^M}";done
Again, ^M is Ctrl+v<enter>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fortran. How to automatically find the starting and ending line of desired variable parekhharsh_j Programming 5 06-24-2011 12:37 PM
Fortran. How to automatically find the starting and ending line of desired variable parekhharsh_j Programming 2 06-23-2011 07:36 AM
GREP - reg exp to find words ending with .V and .TO vikram_cvk Linux - Server 5 12-22-2006 01:47 PM
Annoying files being created ending with ~ zwyrbla Linux - General 5 12-26-2004 02:51 AM


All times are GMT -5. The time now is 01:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration