When i try run this command
rm -rf node_modules
I get this error:
rm: node_modules/core-js/core/function.js: Illegal byte sequence
how can i fix it ?
Looks like theres some encoding issues with this file. You can do:
LC_ALL=C rm -rf node_modules
Or you can try setting these two vars before you run your rm command.
export LC_CTYPE=C
export LANG=C
You can also add this in your .bashrc file but it will cause issues in other places.
Related
What I did were as follows step by step:
Git clone go-ethereum project to my local PC. It is located in
D:\GOPATH\src\github.com\ethereum\go-ethereum. It is the source code
of go-ethereum
Note: The OS is windows 7. Go has already been installed. And GOPATH env has already been set to "D:\GOPATH"
cd /d D:\GOPATH\src\github.com\ethereum\go-ethereum. Then execute
"go install". Some exe files were genereated under D:\GOPATH\bin
directory, and many pkg file with suffix .a were generated under
D:\GOPATH\pkg directory. Everything seems no problem.
Execute "go clean -n -r -i github.com/ethereum/go-ethereum..." to
remove all the generated exe files and .a files. But something very
interesting happened:
In the command's log, it showed that some files are deleted, but actually they are not deleted from disk.
For example, event.a exists under D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum, but the log of "git clean" shows:"rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\event.a"
The detailed information is in the attached images.
It is very strange. The log does not match with the actual result:
A small segment of go clean command is as follows(since there are more than 1300 lines in log, I can not paste all of it):
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\event
rm -f event.test event.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\event.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\common\mclock
rm -f mclock.test mclock.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\common\mclock.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\vendor\github.com\aristanetworks\goarista\monotime
rm -f monotime.test monotime.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\vendor\github.com\aristanetworks\goarista\monotime.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\accounts\abi
rm -f abi.test abi.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\accounts\abi.a
cd D:\GOPATH\src\github.com\ethereum\go-ethereum\accounts\abi\bind
rm -f bind.test bind.test.exe
rm -f D:\GOPATH\pkg\windows_amd64\github.com\ethereum\go-ethereum\accounts\abi\bind.a
But some of the files remain:
The correct answer is actually provided by #Peter in comment. As Peter said "The -n flag causes clean to print the remove commands it would execute, but not run them."
I tried "-x" instead of "-n", and it works well. Thanks Peter. But you posted your answer in comment section, so I have to post your answer here and close this question.
I am following the instructions at https://help.github.com/articles/set-up-git. But when I get to the step
sudo mv git-credential-osxkeychain \
"$(dirname $(which git))/git-credential-osxkeychain"
# Move the helper to the path where git is installed
# Password: [enter your password]
I keep getting errors for dirname. dirname is my /User/myname directory. so I try replacing it with /User/myname, then with /, then with .. Each time it throws a complaint such as
-bash: dirname: is a directory
mv: git-credential-osxkeychain: No such file or directory
Or in the case of .
-bash: ????: command not found
mv: git-credential-osxkeychain: No such file or directory
But when I go to my HD I do see the file git-credential-osxkeychain there under path (ie info) /
You need to input the command
sudo mv git-credential-osxkeychain \
"$(dirname $(which git))/git-credential-osxkeychain"
exactly as it is written; don’t replace dirname with a directory name. (The point of this command is to get your shell to do that replacement itself.)
The password you’re prompted for is your computer’s password—the use of sudo is what’s triggering the password prompt here.
I believe it should be straight forward but either I am having a bad day or I simply can't find what I am looking for.
Please help.
I need to run following commands in MAC Terminal in order to get rid of following entries:
sudo rm -Rf /Applications/Network\ Connect.app
sudo rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
sudo rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
sudo rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
sudo rm -Rf /Library/Widgets/Network\ Connect.wdgt
sudo rm -Rf /usr/local/juniper
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
sudo rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
sudo rm -Rf ~/Library/Preferences/ncproxyd.plist
It does it's job but it's not exactly elegant. I was also thinking about providing this to my colleagues so I wanted to create some sort of .bat file for MAC.
I really spent about half day trying to figure it out but it doesn't work :(
Can somebody help me to create a .sh file or bash file which will do execute the commands above?
Create a script file, let's say it's called deletion.sh and add the lines: -
#!/bin/bash
rm -Rf /Applications/Network\ Connect.app
rm -Rf /Library/Frameworks/net.juniper.DSApplicationServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSCoreServices.framework
rm -Rf /Library/Frameworks/net.juniper.DSNetworkDiagnostics.framework
rm -Rf /Library/Internet\ Plug-ins/net.juniper.DSSafariExtensions.plugin
rm -Rf /Library/Widgets/Network\ Connect.wdgt
rm -Rf /usr/local/juniper
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.bom
rm -Rf /private/var/db/receipts/net.juniper.NetworkConnect.plist
rm -Rf ~/Library/Preferences/ncproxyd.plist
Then, in terminal you need to set the executable flag to the script: -
chmod +x deletion.sh
Note that the executable flag may be removed when the script is copied to another machine or network drive, so you may have to do that after copying.
Finally, you can call the script with sudo
sudo ./deletion.sh
If you want to create a batch file, you have one. That list of commands is your shell script. To execute it, just save hem into a file add the bash command to the front of that file's name:
$ bash commands_I_want_to_execute.txt
If you want to get fancy, you can put a shebang on the top and set the execution bit using chmod. That will make your script a real shell script.
However, in order for your shell script to be found, you need to either prefix it with a path, or put it in a directory that's included in your PATH. Here, I'll just prefix it:
$ chmod a+x commands_I_want_to_execute.txt # Suffix doesn't really matter. It's executable
$ ./commands_I_want_to_execute.txt # Now this will be executed
If you are really bothered by the suffix, change it with the mv command:
$ mv commands_I_want_to_execute.txt commands_I_want_to_execute.sh
NOTE: If you create a file with Text Edit, create it as a plain text file and not as a RTF file.
#!/bin/bash
mkdir /tmp
curl -O http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz /tmp/mucommander.tgz
tar -xvzf /tmp/mucommander.tgz */mucommander.app/*
cp -r /tmp/mucommander.app /Applications
rm -r /tmp
I'm trying to create a shell script to download and extract muCommander to my applications directory on a Mac.
I tried cd into the tmp dir, but then the script stops when I do that.
I can extract all using the -C argument, but the current tgz path is muCommander-0_9_0/mucommander.app, which could change on later builds, so I'm trying to keep it generic.
Can anyone give me pointers where I'm going wrong?
Thanks in advance.
Strip the first path component when you untar the archive, from tar(1):
--strip-components count
(x mode only) Remove the specified number of leading path ele-
ments. Pathnames with fewer elements will be silently skipped.
Note that the pathname is edited after checking inclusion/exclu-
sion patterns but before security checks.
Update
Here is a working bash example of how to, fairly generically, copy the contents of the tgz file to /Applications.
shopt -s nocaseglob
TMPDIR=/tmp
APP=mucommander
TMPAPPDIR=$TMPDIR/$APP
mkdir -p $TMPAPPDIR
curl -o $TMPDIR/$APP.tgz http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz
tar --strip-components=1 -xvzf $APP.tgz -C $TMPAPPDIR
mv $TMPAPPDIR/${APP}* /Applications
# rm -rf $TMPAPPDIR $TMPDIR/$APP
The rm command is commented out for now, verify that it does no harm before you use it.
The following will update your muCommander.
#for the safety, remove old temporary extraction from the /tmp
rm -rf /tmp/muCommander.app
#kill the running mucommander - you dont want replace the runnung app
ps -ef | grep ' /Applications/muCommander.app/' | grep -v grep | awk '{print $2}' | xargs kill
#download, extract, remove old, move new, open
#each command run only when the previous ended with success
curl http://www.mucommander.com/download/nightly/mucommander-current.app.tar.gz |\
tar -xzf - -C /tmp --strip-components=1 '*/muCommander.app' && \
rm -rf /Applications/muCommander.app && \
mv /tmp/muCommander.app /Applications && \
open /Applications/muCommander.app
Beware, after the '\' must following new line, and not any spaces...
How would I go about creating an AppleScript command that when I just run the script (or double click it in Finder?), it would run a set of terminal commands? The set of commands completely remove MySQL, and it has become a pain to constantly write them out. The commands are:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf
There is also another command sudo nano /etc/hostconfig that opens a file and I need to delete a line from the file, but that seems like it'd be too hard to code, so I guess I can do that by hand. But it would be a huge help to do this automatically with a single script.
Would it just be a bunch of these commands?
do shell script (...)
Thanks,
Hristo
Yes, you would use do shell script.
However, for the commands where you execute as super user (sudo) you would instead use with administrator privileges. So, for sudo rm /usr/local/mysql you'd do:
do shell script "rm /usr/local/mysql" with administrator privileges
If your list of commands is long, then it might just be easier to put all your commands into a single shell script file, and then execute that shell script using do shell script:
do shell script "/path/to/shell/script" with administrator privileges
You don't actually need to use AppleScript for this - just put all the shell commands in a text file and give it a .command suffix and make sure it's executable (e.g. chmod +x my_script.command) - this will make it double-clickable in the Finder.
I find that .scpt files work best but this is just a preference thing.
Open "Script Editor" and add the following command:
sudo rm -rf /usr/local/mysql; sudo rm -rf /usr/local/mysql*; sudo rm -rf /Library/StartupItems/MySQLCOM; sudo rm -rf /Library/PreferencePanes/My*; sudo rm -rf /Library/Receipts/mysql*; sudo rm -rf /Library/Receipts/MySQL*; sudo rm /etc/my.cnf; say job completed successfully" with administrator privileges