Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/bin/bash
  2. # first argument is the name of the folder and the c file
  3. fileName=$1
  4. # change to the desired folder
  5. filePath='/Users/apple/Documents/coding/c/c_generated/'
  6. folderToCreate="$filePath$fileName"
  7. fileToCreate="$filePath$fileName/$fileName.c"
  8. helloWorld="#include<stdio.h>\n\nint main(){\n\tprintf(\"Hello world\");\n}\n"
  9.  
  10. if [ ! -d "$folderToCreate" ]; then
  11. echo "creating file at : $folderToCreate"
  12. mkdir $folderToCreate && touch "$fileToCreate"
  13. echo -e $helloWorld >> $fileToCreate
  14. fi
  15. echo "opening file : $fileName"
  16. cd $folderToCreate
  17. vim $fileToCreate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement