In the (C-)shell, how can I remove all files whose filenames contain Ctrl-M? (Don't ask me how I made these!)
            Asked
            
        
        
            Active
            
        
            Viewed 72 times
        
    0
            
            
        
        gammarayon
        
- 92
 - 3
 - 9
 
- 
                    1Does this answer your question? [remove ^M characters from file using sed](https://stackoverflow.com/questions/19406418/remove-m-characters-from-file-using-sed) – thanasisp Aug 30 '20 at 19:11
 
1 Answers
1
            The question is described as "C-)shell". Not clear if OP can use different shell.
Using bash
Using ctrl-v to escape the ctrl-M
rm -i *<ctrl-v><ctrl-m>*
For tcsh
On most systems, csh is supported by tcsh. Depending on you build of tcsh, might be possible to Carriage Return - Ctrl-M, using the sequence . Using  will result in new line. Most likely, this is the result of terminal setting (stty, probably inlcr), which can map between new lines and carriage return.
If this work, then you can remove those files using
rm -i *<ctrl-v><ctrl-j>*
        dash-o
        
- 13,723
 - 1
 - 10
 - 37
 
- 
                    The bash solution worked. For (t)csh, one must include in quotes: `rm -i "*
 – gammarayon Aug 30 '20 at 20:37*"` or `rm -i *" "*`. Thanks a lot!