Advertisement

03.14.2005 at 07:43AM PST, ID: 21349874
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Removing Carriage Return
Zone: IBM AIX Unix
Tags: carriage, return, remove
Hi All,
Below is my script to remove carriage return to convert DOS to unix file format.

*************************************************************************
#!/usr/bin/ksh

if [ $# -ne 1 ]
then
echo "Usage: $0 filename"
exit
fi

sed 's/.$//' $1 > tmp
mv tmp $1
chmod 755 $1

**************************************************************************
This script works fine. Please observe I remove the carriage return and create a new file called 'tmp'. Then I rename 'tmp' to the original filename.
Now I want to do all this in a single line command without having to create a tmp file.

For example:
sed 's/.$//' filename > newfile <---------unacceptable

Instead i want an alternative to the above script which can be done in a single line.

Thank Bunch
ngujja
Start your free trial to view this solution
Question Stats
Zone: OS
Question Asked By: ngujja
Solution Provided By: esanchezvela
Participating Experts: 3
Solution Grade: A
Views: 384
Translate:
Loading Advertisement...
03.14.2005 at 09:36AM PST, ID: 13536945

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 10:24AM PST, ID: 13537349

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 11:13AM PST, ID: 13537806

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 11:41AM PST, ID: 13538100

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 12:26PM PST, ID: 13538517

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 03:11PM PST, ID: 13540112

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.14.2005 at 06:27PM PST, ID: 13541231

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 06:40AM PST, ID: 13544813

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 11:26AM PST, ID: 13547879

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 11:36AM PST, ID: 13548000

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 01:04PM PST, ID: 13548926

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 01:12PM PST, ID: 13549019

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.15.2005 at 01:25PM PST, ID: 13549150

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.14.2005 at 09:36AM PST, ID: 13536945
Hi ngujja,

You may be able to keep the whole file in memory to some degree, but that has an end pretty soon. Files are sequential streams of data on a carrier and in order to remove/add data in the middle of it you have to write the content to a new file first.

Is this homework or have you ever considered installing the AIX DOS Utils? They would give you a dos2unix and unix2dos conversion :-)

======
Werner
 
03.14.2005 at 10:24AM PST, ID: 13537349
Werner,
First It's not homework. I dont know what made you think it is.
Second the machine is remote and Iam just a user so cannot install utils. I did look for dos2unix, it's not there.

If you see the script I have accomplished what I need.

The reason Iam asking this is coz Iam writing a install document, where Iam assuming a normal user without dos2unix, without my script and without the ability to install utils should be able to run a setup script. The setup script for AIX was previously corrupted with carriage return (packaging issue, not in my domain), so Iam trying to find an easy way for the user to convert dos to unix.

I know this can be done redirecting output to temp file and renaming it to setup. It's a two step process, instead was wondering if this could be done in one line. Apparently it can't.

Thanks for tying to help.
ngujja
 
03.14.2005 at 11:13AM PST, ID: 13537806
I want this question to be closed/deleted and points refunded, since there is no solution.

thanks
ngujja
 
03.14.2005 at 11:41AM PST, ID: 13538100
http://www.experts-exchange.com/Q_21350244.html is a request to modify or close this question.  Four days are given to solicit input to the closing recommendations.

EXPERTS: Please leave your thoughts regarding the request for this question and/or specific recommendations for closing this question here.  In the absence of such comments, the question will be handled as follows:
>>> Delete / Refund

ee_ai_construct (replacement part #xm34)
Community Support Admin
 
03.14.2005 at 12:26PM PST, ID: 13538517
No delay needed, a delete is OK
 
03.14.2005 at 03:11PM PST, ID: 13540112

Rank: Master

Not that it's any of my business - But Werner gave a valid answer with a good explanation (See last paragraph of http://www.experts-exchange.com/help.jsp#hi39 ) and the thread is worth saving.

Also, there may be better ways of doing the conversion - See http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21348774.html and especially Tintins technique at the end, to ensure unique filenames and only do the "mv" if conversion is successful.
 
03.14.2005 at 06:27PM PST, ID: 13541231
I agree with tfewster, also among other possible solutions here is one using ex...

unix_prompt> cat ex_script
%s/.$//
wq

unix_prompt> ex - filename < ex_script

you could also use Perl, to read all the file in memory then replace the regex .\n for just \n and then save the file back to its original place. and so on and on...

regards,
esv.
 
03.15.2005 at 06:40AM PST, ID: 13544813
Thanks experts

It was never my intention to be disrespectful to anyone in here. Iam trying to solve my problem that's all.

Regarding some suggestions left in the thread, thanks for that.

I exactly did'nt understand how ex can be used to solve this problem? Again I cannot use a script or utility for this.
I cannot use Perl, coz the file he is trying to convert might be big. This might lead the user to commit some errors.

Ideal situation is the user enters a one line command and voila the file is in unix format now.

Thanks
ngujja
 
03.15.2005 at 11:26AM PST, ID: 13547879

Rank: Master

I don't think anyone read or meant any disrespect - I thought Werners explanation was good, and being told "It can't be done" might save someone else hours of work trying to find a solution.  But then esanchezvela posted a method (we) had not thought of!

`ex` should be standard on all Unixen; I think it will still create a temporary working file, in /tmp or /var/tmp - which may be a problem if you are converting huge files and are short on space -  but `ex` cleans up after itself on exit.

You could embed it in your current script by replacing your sed/mv/chmod lines with:

ex - $1 << EOF
%s/.$//
wq
EOF

Assisted Solution
 
03.15.2005 at 11:36AM PST, ID: 13548000

vi, vim and ex can be used for batch editing as well for interactive usage, I bet most of the time those three, specially vi and vim are used interactivly.

when you feed ex with a commands file using  "ex - [your_big_file_here] < [batch_commands]"

you are telling ex not to expect a tty like device and that it is supposed to work in [your_big_file_here] and it has to follow the directions provided in [batch_commands] filename.

sort of like sed but the edits are done in place and you can go back to the first line or wherever you want . ex will follow the commands you provide in the batch file.

for example, with these instructions I comment out some entries from /etc/inittab, that might cause problems on system restart after finishing a mksysb restore on our production environment....

1,\$global/ldap/s/\(^[^:]*\)/:\1/
1,\$global/jac/s/\(^[^:]*\)/:\1/
1,\$global/tsm/s/\(^[^:]*\)/:\1/
1,\$global/db2/s/\(^.*\)/:\1/
1,\$global/ora/s/\(^.*\)/:\1/
1,\$global/adsm/s/\(^.*\)/:\1/
1,\$global/rctma/s/\(^.*\)/:\1/
1,\$global/cron/s/\(^.*\)/:\1/
1,\$global/rclocal/s/\(^.*\)/:\1/
1,\$global/mysql/s/\(^.*\)/:\1/
1,\$global/suptools/s/\(^.*\)/:\1/
1,\$global/cdserv/s/\(^.*\)/:\1/
1,\$global/nfs/s/\(^.*\)/:\1/
wq


the /etc/inittab is not too big for sed but I wanted to do an inplace edit so, I followed the ex path and it works very nicely.

regads,
esv
Accepted Solution
 
03.15.2005 at 01:04PM PST, ID: 13548926
Thanks esanchezvela and  tfewster for spending time on this.

The solution requires user to interact with shell, but I think I can expect the user to atleast type in commands. I can put this in script, but as I said script might not be available whereas a document might.

I guess I have to request not to close this question now ;-)

ngujja
 
03.15.2005 at 01:12PM PST, ID: 13549019
As long as it solves the problem ... I only tried to answer the original question :-)
 
03.15.2005 at 01:25PM PST, ID: 13549150
Appreciate everybody's contribution
 
 
20080236-EE-VQP-29