Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There are plenty of text manipulation tools such as awk, tr, and sed which can modify a file in the manner you describe. I would choose sed based on my stronger experience with it.
What is your experience with scripting, as well as any of these tools?
Have you attempted anything as yet?
The most common notations for control characters is to write them in octal, such as \015 and \012, when specifying them to the command to perform the modification.
First I suggest a web search using the term, "append characters to the end of line using sed"
As common as I have used sed, I myself had to look it up.
I typically do search/replace versus add stuff. The hits I've seen though seem very reasonable and I've learned about the $ character for use in search-replace.
Next, suggest you consider reading the My Bash Blog link here, or same from my signature.
While I wrote that to help people debug bash scripts, please note that in the introduction for it I give links to the standard Bash scripting guides for basic and advanced, and I also make the comment that, "Whatever you can type on a command line, you can write in a script." The meaning there is that you can use sed, tr, or awk in the command line to try things out and then you can choose to put that command into a small script, if that is your choice. Noting also that using something like sed, the output typically goes to stdout, thus not modifying your file, and once you have the tuning of the command correct for your requirements, you can use the ">" Input-Ouput redirector to redirect stdout to a final result file where you have the added CR-LF as you wish it to be.
In addition, adding CR,LF to the end of lines is basically converting a text file from Unix to DOS format. Searching on how to convert a text file from Unix to DOS format should provide some help.
As stated there are a few ways using tr, sed, awk, perl or the unix2dos script which is typically available in the repositories in most of the major distributions.
Quote:
I would be inserting code after the file has been moved.
Please explain and what type of text file you trying to convert?
sed: -e expression #1, char 2: extra characters after command
Leave the -e out of that command.
Do not use wildcard characters for now.
Have you confirmed if these are Unix file types and that all you wish to do is convert them to DOS file types? If so, why aren't you considering the utility unix2dos?
Have you confirmed if these are Unix file types and that all you wish to do is convert them to DOS file types? If so, why aren't you considering the utility unix2dos?
To be honest with you, I'm not expecting trickydba to answer my question about this - he/she appears to have ignored my question and the previous comment on the same subject completely.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.