Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. cp /my/long/path/here/thing.txt /my/other/path/here/cpedthing.txt
  2.  
  3. cp: cannot create regular file `/my/other/path/here/cpedthing.txt': No such file or directory
  4.  
  5. COMMAND1 && COMMAND2
  6. mkdir -p /my/other/path/here/ && touch /my/other/path/here/cpedthing.txt
  7.  
  8. FILE=./base/data/sounds/effects/camera_click.ogg
  9.  
  10. mkdir -p "$(dirname "$FILE")" && touch "$FILE"
  11.  
  12. mktouch() {
  13. if [ $# -lt 1 ]; then
  14. echo "Missing argument";
  15. return 1;
  16. fi
  17.  
  18. for f in "$@"; do
  19. mkdir -p -- "$(dirname -- "$f")"
  20. touch -- "$f"
  21. done
  22. }
  23.  
  24. mktouch ./base/data/sounds/effects/camera_click.ogg ./some/other/file
  25.  
  26. #!/bin/sh
  27. for f in "$@"; do mkdir -p "$(dirname "$f")"; done
  28. touch "$@"
  29.  
  30. mkdir -p /my/other/path/here/
  31. touch /my/other/path/here/cpedthing.txt
  32.  
  33. install -D /my/long/path/here/thing.txt /my/other/path/here/cpedthing.txt
  34.  
  35. install -D <(echo 1) /my/other/path/here/cpedthing.txt
  36.  
  37. if [ ! -d /my/other ]
  38. then
  39. mkdir /my/other/path/here
  40. cp /my/long/path/here/thing.txt /my/other/path/here/cpedthing.txt
  41. fi
  42.  
  43. mkdir -p /my/other/path/here;cp /my/long/path/here/thing.txt /my/other/path/here/cpedthing.txt
  44.  
  45. mkdir -p /my/other/path/here
  46. cp /my/long/path/here/thing.txt /my/other/path/here/cpedthing.txt
  47.  
  48. cd /my/long
  49. cp --parents path/here/thing.txt /my/other
  50.  
  51. ptouch() {
  52. for p in "$@"; do
  53. _dir="$(dirname -- "$p")"
  54. [ -d "$_dir" ] || mkdir -p -- "$_dir"
  55. touch -- "$p"
  56. done
  57. }
  58.  
  59. mkdir -p /code/tmp/other/path/here
  60. touch /code/tmp/other/path/here/cpredthing.txt
  61.  
  62. mkdir -p /code/tmp/other/path/here &&
  63. touch $_/{cpredthing.txt,anotherfile,somescript.sh}
  64.  
  65. mkdir -p /code/tmp/other/path/here
  66. touch /code/tmp/other/path/here/cpredthing.txt /code/tmp/other/path/here/anotherfile /code/tmp/other/path/here/somescript.sh
  67.  
  68. rm -rf /abs/path/to/file; #prevent cases when old file was a folder
  69. mkdir -p /abs/path/to/file; #make it fist as a dir
  70. rm -rf /abs/path/to/file; #remove the leaf of the dir preserving parents
  71. touch /abs/path/to/file; #create the actual file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement