What are some ways I can manipulate a file in shell? Imprimir

  • 0

mv

mv fred wilma

This moves fred to a file named wilma. This is the Unix way of renaming a file.

mv fred flintstones/fred

This moves fred to a file named fred in the subdirectory flintstones. This example could have been written mv fred flintstones/ as well, and the filename fred would have been retained in the new directory.

After executing this command, there will no longer be a fred file in the current directory.


cp

cp fred wilma

This copies fred to a file named wilma.

cp fred flintstones/fred

This copies fred to a file named fred in the subdirectory flintstones.


rm

rm flintstones

This removes a file named flintstones.

rm -rf flintstones

This removes a directory named flintstones. The -r removes the directory, the -f forces it to remove files without asking you before it deletes each one.

Esta resposta foi útil?

« Voltar