- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- dos2unix with find command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 03:52 PM
тАО08-28-2005 03:52 PM
I would like to use the find command along with the dos2unix utility to locate file containing the ^M character and convert them to the standard UNIX file.
This is what I've done:
find . -type f -name "*.sh" -exec dos2unix {} \;
However, the command above only displayed the file contents(without the ^M) at the std I/O, and in the file itself.
May I know how do I include both the original file to modify and the new output file to the dos2unix command arguments, executed with the find command?
bash-2.03$ dos2unix pollerka pollerka
could not open /dev/kbd to get keyboard type US keyboard assumed
could not get keyboard type US keyboard assumed
bash-2.03$
Also, how do I execute dos2unix in silent mode?
Could anyone help out?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 04:50 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 07:34 PM
тАО08-28-2005 07:34 PM
Re: dos2unix with find command
dos2ux writes output to stdout, you must redirect output to a file if you want dos2ux "silent".
dos2ux infile >outfile
then you can move the outfile to the original name
mv outfile infile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 09:13 PM
тАО08-28-2005 09:13 PM
Re: dos2unix with find command
have a look at the manpage. It states, that dos2ux writes to standart output. So the command works as designed.
In your case you have to redirect the output to a filename e.g. dos2ux inputfile > outputfile.
If you want to combine this with a find command you can do a loop for each file find returns. Something like:
for filename in 'find ....'
do
dos2ux $filename > $filename.new
done
Hope this helps
Regards Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 10:18 PM
тАО08-28-2005 10:18 PM
Re: dos2unix with find command
# find . -type f -name "*.sh" | awk '{ print "dos2unix "$0" "$0".unix" }' | ksh
It will create modified file as
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2005 10:20 PM
тАО08-28-2005 10:20 PM
Re: dos2unix with find command
# find . -type f -name "*.sh" | awk '{ print "dos2ux "$0" "$0".out" }' | ksh
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2005 04:39 AM
тАО08-29-2005 04:39 AM
Re: dos2unix with find command
# find . -type f -name "*.sh" | xargs -i dos2unix {} {}.ux
regards!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2005 07:57 AM
тАО08-29-2005 07:57 AM
Re: dos2unix with find command
perl -i -pe 'chomp;print $_,"\n";' `find . -type f -name "*.sh"`
This will in effect "chomp" the trailing cr. The -i option tells perl to read in the original and update it "in place".
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2005 09:08 PM
тАО08-29-2005 09:08 PM
Re: dos2unix with find command
I tried your method using PERL, but obtained the error shown below:
bash-2.03$ perl -i -pe 'chomp;print $_,"\n";''\find . -type f -name "pollera"'
String found where operator expected at -e line 1, near "name "pollera""
(Do you need to predeclare name?)
syntax error at -e line 1, near "name "pollera""
Execution of -e aborted due to compilation errors.
May I know where exactly is my error, as I believe I've copied exactly what you showed.
Could you or anyone else help out?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-30-2005 02:21 AM
тАО08-30-2005 02:21 AM
Re: dos2unix with find command
Try copying the command from the web page.
Also, try this command instead-
perl -i -pe 's/\r//g' `find . -type f -name "*.sh"`
The 's/\r//g' is the perl statement to execute. The `find ...` executes the find returning the list of file names to be processed.
HTH
-- Rod Hills