- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to catch DOS carriage return by egrep
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
Forums
Discussions
Discussions
Discussions
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
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-04-2004 02:36 AM
08-04-2004 02:36 AM
we have some files initially generated in some editors in windows environment and uploaded, which have DOS carriage return, it has a trailing '^M' if opened in vi, how can I identify those files by grep or egrep?
thanks,
Gary
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:42 AM
08-04-2004 02:42 AM
Re: how to catch DOS carriage return by egrep
I think you need to look at dos2ux command.
man dos2ux
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:42 AM
08-04-2004 02:42 AM
Re: how to catch DOS carriage return by egrep
- check out 'dos2ux', a standard tool
- using 'man ed' you'll see you can express the dos line ends ( CR - LF ) with \r$
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:45 AM
08-04-2004 02:45 AM
Re: how to catch DOS carriage return by egrep
grep ^V^M$ file
The ^V should allow you enter the ^M as a single character. The $ specifies that you're checking at the end of the line.
To remove them, use
cat file | sed -e s/^V^M$//g > new_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 02:49 AM
08-04-2004 02:49 AM
Re: how to catch DOS carriage return by egrep
thanks again,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2004 03:09 AM
08-04-2004 03:09 AM
Re: how to catch DOS carriage return by egrep
#!/usr/bin/sh
INFILE=/mydir/myfile
awk 'BEGIN { X=0 } /.*\015$/ {X = 1; exit(X)} END {exit(X)}' < ${INFILE}
STAT=${?}
if [[ ${STAT} -eq 1 ]]
then
echo "File ${INFILE} has CR's"
else
echo "No CR's"
fi
exit ${STAT}