Equivalent command in Linux

1

I have a question, in windows I use a command that allows me to locate myself inside a directory and create a text file with all the existing files in the directory in question the command that I used for it is the following

cd /carpeta/ruta_de_archivos
copy *.* salida.txt

If there are 5 or 200 files in my path .prn or txt, the command I use simply creates a file named output.txt with the consecutive content of my files,
I have just flown Windows and installed 100% Xubuntu but I do not know how I can do what I used to do from Windows as I indicated.

    
asked by Jose M Herrera V 11.11.2018 в 02:02
source

2 answers

2

The answer involves three points:

  • The cat command that allows you to "concatenate" one or more files
  • Wildcard expansion of bash
  • And the redirection by > of an output to a file

Something like this:

cat *.* > salida.txt
    
answered by 11.11.2018 / 02:10
source
1

I'm not sure the cat command accepts wildcards , so the safe route, for me, would be:

cd /ruta/de/archivos
rm salida.txt
for file in *; do cat $file >> salida.txt; done

In this way, the interpreter of commands is in charge of doing the iteration for all the files.

    
answered by 11.11.2018 в 02:16