Score:0

How to write all file name in a text file and output to a different folder (directory)?

es flag

I have a folder with about 5000 files. I want the file name into a text file. I tried ls >> Out_file.txt but I want the output file to be saved in a different directory/folder.

Score:1
cn flag

Specify a different file path after the redirection symbol >>.

You currently only provide the file name. The file therefore will be saved in the current directory. Prepend the path where the file should be stored, and it will be stored there.

Example with absolute path /home/user/test/:

ls >> /home/user/test/Out_file.txt

Example with relative path: it will store the file in the folder above the one your in, ex. your in /home/user/test/ and the file will be in /home/user/:

ls >> ../Out_file.txt
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.