Anyone have a shell script to remove controlM character from all the files in a directory
Dev_9
0
Newbie Poster
Recommended Answers
Jump to PostEasily done, but what do you do if the folder contains an executable or an image file?You don't want to delete ^M in those.
Jump to PostYou can use dos2unix. Just run
dos2unix *.cpp
(or whatever the suffix is).
Jump to PostForgot to ask. Is this for Windows or for linux? I would imagine linux or there would be no need to strip cr but you never know.
Jump to PostWhat do you mean by "shell script" then?
What environment are you working in?
Can you run bash? If so, you could run the following one-liner in the directory with the cpp files. First make a new directory in it called "fixed" where the fixed files will go.
All 14 Replies
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Dev_9
0
Newbie Poster
John_191
15
Newbie Poster
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Dev_9
0
Newbie Poster
John_191
15
Newbie Poster
Dev_9
0
Newbie Poster
Dev_9
0
Newbie Poster
John_191
15
Newbie Poster
Dev_9
0
Newbie Poster
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
John_191
15
Newbie Poster
Reverend Jim
4,678
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.