I'm doing the react tutorial and I'm having trouble with step 3.
I put the lines in the tutorial
cd my-app
rm -f src/*
into my node.js command prompt and got "'rm' is not recognized as an internal or external command, operable program or batch file."
How can I work around this problem?
This doesn't go in your node.js prompt. It's an OS command. If you are using linux, OSX, or ubuntu-on-windows, you should type it in your terminal.
If you are using windows, you can use rmdir \S \Q src
If you are in linux or Mac OS you should do
cd my-app && rm -f src/*
This will remove all the files in src and will keep the folders its files.
If you want to remove everything from src then use:
cd my-app && rm -rf src/*
Related
I want to delete multiple folders & files at once and the command should not broke even if some directories or files aren't preset. Also I use wildcards(*) to combine folder & file names.
I have the following command to delete folders in Ubuntu
rm -rf dist pkitree srktable cst_sign* cst_encrypt* *.log out
However when I try to do accompany the same in Windows batch like,
rd /s /q dist pkitree srktable cst_sign* cst_encrypt* *.log out 2> NUL
I still get error status and the wildcards are not recognised. Can someone help me achieving this behaviour in Windows as well?
You can try :
powershell -Command "Remove-Item -Recurse dist, *.log"
When compiling, I always place the build in a separate directory. For example:
mkdir build
cd ./build
(cd ..; ./bootstrap)
../configure
make
Since I have plenty of RAM the aim is to compile on a TMPFS.
The script gets the name of the project, uses it for the name for the directory created in $XDG_RUNTIME_DIR/build and finally links it.
# setup-build.sh
#!/usr/bin/bash
set -e
my_project_name=$(basename $(pwd))
my_project_build_dir="$XDG_RUNTIME_DIR/build/$my_project_name"
mkdir -p $my_project_build_dir
ln -s "$my_project_build_dir" "$(pwd)/build"
The script runs without a problem. But, when I do cd ./build; ../configure it returns an error: bash: ../configure: No such file or directory. The file most certainly does exist, but Bash can't find it!
I altered the script to this:
#!/usr/bin/bash
set -e
my_project_src_dir="$(pwd)"
my_project_name="$(basename $(pwd))"
my_project_build_dir="$XDG_RUNTIME_DIR/build/$my_project_name"
mkdir -p "$my_project_build_dir"
ln -s "$my_project_build_dir" "$(pwd)/build"
cd "$my_project_build_dir"
echo "$my_project_src_dir" > "./project-src-dir.txt"
To compile I have to type cd ./build; $(cat ./project-src-dir.txt)/configure; make. This causes Bash complete to partial break, though. As in I can't TAB complete file names from $my_project_src_dir with this method, but TAB completion for arguments works fine. Ifautoconf is needed: (cd $(cat ./project-src-dir.txt); ./bootstrap). If anyone has any other ideas I would still prefer to be able to just do ../configure, although this will have to do for now.
Edit: Had to change my_project_name="$(basename '$my_project_src_dir') to my_project_name="$(basename $(pwd))" as it was taking '$my_project_src_dir' literally.
I am new to Ubuntu and I have recently learned how to open a folder in the terminal for example
cd Desktop
A problem occurred when I tried to open a folder called "ovn 1.2.1". When running
cd ovn 1.2.1
in the terminal, the terminal answers with "could not find any folder called ovn".
If by map you mean directory such as Desktop, on your terminal, escape the spaces, like this:
$ cd ovn\ 1.2.1
Or, enclose in quotes, ' or " quotes are fine:
$ cd 'ovn 1.2.1'
You can use quotes ("s) to shield the directory name from the shell:
mureinik#computer ~ $ mkdir "ovn 1.2.1"
mureinik#computer ~ $ cd "ovn 1.2.1"
mureinik#computer ~/ovn 1.2.1 $
Try this:
cd ovn\ 1.2.1
you can also start typing cd ovn and then hit Tab key for autocomplete
Try ovn\ 1.2...
\ is treated as space in terminal.
I have a custom shell script to make twitter bootstrap from source and then move the files to my node.js app's /lib file:
rm -r bootstrap
make bootstrap
mv -f bootstrap/css/* ../../lib/public/css
mv -f bootstrap/img/* ../../lib/public/img
mv -f bootstrap/js/* ../../lib/public/js
Running this from the shell works just fine using ./make_bootstrap.sh
Now I've created a Makefile for my full app (mainly compiling coffeescript and easy test initialization) and want to have a command that executes this custom shell script to build bootstrap. Here is my makefile
REPORTER = spec
all: build
build:
#./node_modules/coffee-script/bin/coffee \
-c \
-o lib src
bootstrap:
#./src/bootstrap \
./make_bootstrap.sh
clean:
rm -rf lib
mkdir lib
watch:
#./node_modules/coffee-script/bin/coffee \
-o lib \
-cw src
test:
#./node_modules/mocha/bin/mocha \
--reporter $(REPORTER) \
test/*.coffee
.PHONY: build bootstrap clean watch test
with the relevant command being 'make bootstrap'. However when I run make bootstrap from the command line all I get is this error:
make: ./src/bootstrap: Permission denied
make: *** [bootstrap] Error 1
Originally I had assumed that it was a permission error but even setting all permissions on files (chmod 777) results in nothing. Files I have given full permissions at this point include the root Makefile, my custom shell script in the bootstrap folder and the makefile within the bootstrap folder itself.
EDIT:
Based on the comments I have refactored to this
bootstrap:
rm -r src/bootstrap/bootstrap
$(MAKE) -C ./src/bootstrap bootstrap
mv -f src/bootstrap/bootstrap/css/* lib/public/css
mv -f src/bootstrap/bootstrap/img/* lib/public/img
mv -f src/bootstrap/bootstrap/js/* lib/public/js
This duplicates the functionality of the shell script I had before (moving files for my custom project) and still uses the standard makefile that Twitter Bootstrap ships with. Much cleaner... I'm going to live the original answer below so people can see the evolution and refactor.
OLD ANSWER
Ok thank you guys in the comments for pointing my in the right direction. This solution works:
bootstrap:
cd ./src/bootstrap; \
./make_bootstrap.sh
What happens is it executes the change directory (in a sub process so it doesn't affect where I run make from) and then executes the custom script. It seems as if I probably shouldn't be using something like this in a makefile since it feels 'dirty'; perhaps a more clean way to do it would be to invoke the LESS compiler myself and mimic the makefile provided by bootstrap. I'm using this for a tiny personal project though so it does the job.
look at this steps:
:~$ cd programacion/
:~/programacion$ cd sports/
:~/programacion/sports$ cd src/
:~/programacion/sports/src$ cd Sports/
:~/programacion/sports/src/Sports$ cd PlatformBundle/
:~/programacion/sports/src/Sports/PlatformBundle$ cd Entity/
:~/programacion/sports/src/Sports/PlatformBundle/Entity$ cd /
:/$
being in this moment in the last prompt, is there any way to go directly to programacion/sports/src/Sports/PlatformBundle/Entity since it is the last path i have visited?
You can use the following shortcut to the last directory:
cd -
For example:
kbrandt#alpine:~$ pwd
/home/kbrandt
kbrandt#alpine:~$ cd src
kbrandt#alpine:~/src$ cd -
/home/kbrandt
kbrandt#alpine:~$ cd -
/home/kbrandt/src
kbrandt#alpine:~/src$
Another option would be to use the $OLDPWD shell variable.
bash's pushd and popd do what you want, and more.
$ help pushd
$ help popd
You can also download the Teleport script, analogous to bash history, but for directories.