LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-05-2011, 10:40 AM   #1
pdiv
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Rep: Reputation: Disabled
dos2unix command in shell scripting


Hello Everyone,

I am new to shell scripting..I really need ur help or guidance here..I have a text file where i have to use dos2unix command.

Now the problem is how do i pass dos2unix command in the shell scripting after it had read the text file ??
And give out the new text file.

I hope you got my question.
THANKS,
 
Old 07-05-2011, 10:44 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Hi and welcome to LinuxQuestions!

Actually I don't get your questions. What do you mean by "after it had read the text file"? The dos2unix command actually modify the input file by default, but if you want to preserve the original file and create a new copy in unix format, you can do
Code:
dos2unix -n infile outfile
Please show us your code to clarify your issue. Thanks.
 
Old 07-05-2011, 02:00 PM   #3
pdiv
LQ Newbie
 
Registered: Jul 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
sorry..Not reading text files but
it has to take the filename and it has to use the command dos2unix for that particular filename.

please help me..
 
Old 07-05-2011, 02:06 PM   #4
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Code:
#!/bin/bash

dos2unix $@;
Save the code as a script, make it executable, then run it like "./script.sh some_file_name some_new_file_name"
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dos2unix: command not found thomas2004ch Linux - Software 8 07-23-2010 04:16 AM
shell scripting/ the fc -l command ! mayaabboud Linux - Newbie 12 01-03-2008 06:38 PM
Shell Scripting - use the output of a command as an argument for another timgiffney Programming 6 04-17-2006 11:13 AM
Use of dos2unix command Karthikeyan Gurusamy Linux - Newbie 3 02-02-2006 06:32 AM
dos2unix command on a folder raghunandan Linux - Software 1 12-12-2005 07:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration