- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed to remove control M characfer
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
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
тАО01-25-2010 01:50 PM
тАО01-25-2010 01:50 PM
sed to remove control M characfer
I am using the below sed code to remove the control M character from a file, however I am getting an error.
sed -e 's///g' $filename > $TMP/$filename
sed: 0602-410 The first regular expression cannot be null.
Any help would be appreciated.
Thanks.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2010 02:03 PM
тАО01-25-2010 02:03 PM
Re: sed to remove control M characfer
You can use 'dos2ux' or Perl:
# dos2ux < file > file.new
# perl -pe 's/\r$//g' file > file.new
...or with an "inplace" update:
# perl -pi.old -e 's/\r$//g' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2010 02:12 PM
тАО01-25-2010 02:12 PM
Re: sed to remove control M characfer
In reality we can drop the 'g'lobal action from the one-liner Perl above, since the substitution is performed if there is a carriage-return ('\r') anchored to the end of a line. Thus there will only be one.
In HP's 'sed' you are relegated to something like:
# sed -e 's/^M//' file > file.new
...where the ^M is typed at the command line by pressing the "CONTROL v m" key sequence.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2010 03:34 PM
тАО01-25-2010 03:34 PM
Re: sed to remove control M characfer
Unfortunately you can't do that for ksh, I get control-J. You can do it in vi.
You can also use vi directly on the file or use tr(1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2010 03:52 PM
тАО01-25-2010 03:52 PM
Re: sed to remove control M characfer
> Dennis: Unfortunately you can't do that for ksh, I get control-J.
That is interesting. I see this too if I switch to the 'ksh' shell. With the standard Posix shell the control+v+m sequence works fine at the command line.
I agree, rhansen could also do:
# tr -d "\015" < file > file.new
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-25-2010 08:13 PM
тАО01-25-2010 08:13 PM
Re: sed to remove control M characfer
It might be helpful if you would reveal the
particular AIX version where you're trying to
do the work. "uname -a" should say enough.
> You can use 'dos2ux' [...]
Perhaps not on AIX:
blue# man dos2ux
Manual entry for dos2ux not found or not installed.
blue# type dos2ux
-bash: type: dos2ux: not found