LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-01-2009, 10:33 PM   #1
Shaitan00
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Question Equivalant of Windows DIR /S > M:\File.txt using Ubuntu LiveCD?


I have some files and folders on a drive (OS) which I want to write to a text file (long story short, drive it dying, some files I could not backup because copy failed, want to generate a list of them all).

If this was Windows I would run:
DIR /S > M:\File.txt
This would create a text file called File.txt on the M:\ drive which contained a list of all the files & folders ...

Now, because the drive was dying I am using Ubuntu LiveCD (Linux) to backup my files ... now the question is how can I accomplish the same thing in Ubuntu?

Any advice, help, information would be much appreciated.
Thanks,
 
Old 07-01-2009, 10:47 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,839

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
"ls -R1F > file.txt" - the format will be different of course, but the names will be there (F shows dirs with a trailing /).

Last edited by syg00; 07-01-2009 at 10:52 PM. Reason: more options
 
Old 07-01-2009, 11:21 PM   #3
Shaitan00
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Will I be able to read/open the file in Windows afterwards?
I mean ... is a .txt a .txt under both Linux and Windows?
Thanks,
 
Old 07-01-2009, 11:37 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,839

Rep: Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822Reputation: 1822
Not directly - windows uses crlf; lots of utilities to do it (editpad lite for Windows is good - free and will handle both) but this should work
Code:
ls -R1F > file.txt 
sed -e 's/$/\r/' file.txt > win_file.txt
 
Old 07-01-2009, 11:37 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Sort of. It'll create a plain ascii text file, but Linux uses just <lf> whereas MS uses <cr><lf>.
You can use unix2dos util to change the line endings.
I believe(?) Notepad can read it regardless, but might look odd.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
cat onelinefile.txt >> newfile.txt; cat twofile.txt >> newfile.txt keep newline? tmcguinness Programming 4 02-12-2009 07:38 AM
Skype or equivalant for ubuntu 8.04 64 bit architecture hallows1 Linux - Software 1 04-29-2008 03:24 AM
How can read from file.txt C++ where can save this file(file.txt) to start reading sam_22 Programming 1 01-11-2007 06:11 PM
Compress dir keep file/dir permissions powadha Linux - General 1 11-14-2006 08:07 PM
How to convert a txt file to be a db file in Redhat linux 9? winnie Linux - Newbie 3 06-27-2003 09:33 AM


All times are GMT -5. The time now is 04:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration