LINUX LITE 7.2 FINAL RELEASED - SEE RELEASE ANNOUNCEMENTS SECTION FOR DETAILS


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating and saving *.txt files from command line orders output.
#5
Quote:why root you ask? well, not sure whether or not it has to do with *ls command or that you're working with directories but your non-root user has no permission to perform that action, I think it's harmless, but apparently you're not allowed unless root, maybe someone more experienced than me could explain the why.


There is no need to use sudo or su for the ls command.  When you do that you'll end up with problem that the generated file is owned by root instead of regular user.  Regular user will be able to read file, but won't be able to make changes or delete it without also being root.  Don't know why you experienced a problem with it.  Maybe you accidentally mis-typed something.  This should work without a problem as regular user:
Code:
ls > ls.txt


Also, if you want to get rid of the weird characters generated in output of that command (assuming directories may be part of the output) use this instead:
Code:
ls --color=never > ls.txt


The terminal colorizes directory listings to make them stand out from regular files.  If you generate a text file from command line above and the output contains directories, you'll see strange characters around those directory listings because text editor can't do colors.  For example, generate a text file listing contents of your Home directory, then open it with text editor to see what I'm talking about.
Code:
cd ~
ls > home.txt


Now do it again with the "--color=never" option.
Code:
ls --color=never > home.txt
Try Linux Beginner Search Engine for answers to Linux questions.
Reply


Messages In This Thread
Re: Generating and saving *.txt files from command line orders output. - by gold_finger - 10-07-2017, 03:26 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)