Posts

Showing posts with the label unix

./ Dot Slash not working to execute Shell Scripts

Image
Clash Royale CLAN TAG #URR8PPP ./ Dot Slash not working to execute Shell Scripts I'm definitely a command line novice. I have recently lost the ability to execute shell scripts using ./script.sh I am still able to execute shell scripts using: sh script.sh My $PATH is as follows: /Users/goodguy/.pyenv/shims:/Users/goodguy/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/local/sbin:/Users/goodguy/.rvm/bin I am using MacOS. I'd appreciate any insight into what I may be doing wrong Perhaps it doesn't have the executable flag set. Check with ls -lart script.sh and look for x . You can set it to executable using chmod +x script.sh – Matthew Darnell 14 mins ago ls -lart script.sh x chmod +x script.sh By clicking "Post Your Answer...

Script to keep only the last three directories under each of the subdirectory

Image
Clash Royale CLAN TAG #URR8PPP Script to keep only the last three directories under each of the subdirectory Assume that I have a directory structure as follows: applications │ ├── configs │ ├── 1.0.0.1 │ └── 1.0.2.1 │ ├── logs │ ├── l1.0.3 │ └── l2.0.4 │ └── src ├── s1.p.8 ├── s1.p.9 └── s2.p.10 Now I want to delete the folders under each subdirectory under applications directory and keep only the last three under each subdirectory Eg: under applications directory we have like configs, logs,src, test, etc. The requirement is that I need to keep only the last three directories under each of these directories(configs, logs,src, test, etc). Thanks. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Purposely aborting a Unix shell on an if condition

Image
Clash Royale CLAN TAG #URR8PPP Purposely aborting a Unix shell on an if condition I have created a shell script . I want to abort it on an if condition. I used exit command for example: exit 1 or exit 42. It doesn't fail the shell execution. Please help!! By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.