cd

Bash - change path to the folder with the highest version number

余生颓废 提交于 2019-12-11 17:27:19
问题 I have the below folder structure MyPackage └── versions └── MyPackage-1.0 └── src MyPackage-1.0.1 └── src MyPackage-2.0 └── src I am writing a bash script to build the latest version of the package and retrieve the build artifact. Part of that step is to change to the directory of the latest package: cd MyPackage/versions/MyPackage-2.0/src How can I write my bash script such that it will always choose the highest version subfolder (so in this case MyPackage-2.0 but in the future it could

How to find out the path that will be used in `cd -`?

断了今生、忘了曾经 提交于 2019-12-11 08:44:48
问题 I know that it is possible to use cd - to switch between 2 paths: user@server:~$ cd a user@server:~/a$ cd ~/b user@server:~/b$ cd - /home/user/a user@server:~/a$ cd - /home/user/b user@server:~/b$ I want to use this feature to do something with the previous path. Maybe there is some variable that points to the previous path so I can do thins like: user@server:~/a$ cd ~/b user@server:~/a$ ls -d $PREVIOUS_PATH /home/user/a user@server:~/a$ cp file $PREVIOUS_PATH # will copy file to /home/user/a

why calling cd shell command through system() or execvp() from a child process won't work?

微笑、不失礼 提交于 2019-12-11 02:58:43
问题 I understand that i am supposed to use chdir() but I just need an explanation as to why calling cd shell command through system or execvp() from a child process would not work? Thanks!! 回答1: Because chdir only modifies the environment of the current process. It can't touch the environment of the parent. See also the link posted by tripleee. 来源: https://stackoverflow.com/questions/7120493/why-calling-cd-shell-command-through-system-or-execvp-from-a-child-process-w

How to change to a subdirectory and run an exe using a bat file in a Windows 7 system?

不羁的心 提交于 2019-12-10 18:14:18
问题 Using a bat file, I want to change to a sub directory of folder which bat file is in, and run my_application.exe in that directory, I try: cd /d %cd%\my subdirectory START %~dp0my_application.exe But it doesn't work, it says it can't find my_application.exe 回答1: Just indicate to start command what program to start and what should be the starting folder for it. Without the cd command, it can be written as start "" /d "%~dp0my_subdirectory" "my_application.exe" if the my_application.exe is

Going n folders up with a terminal command?

≯℡__Kan透↙ 提交于 2019-12-10 17:55:35
问题 cd .. goes one folder up. Is there a (one-line) command to go n folders up? 回答1: You sure can define a function to do that: $ go_up() { for i in $(seq $1); do cd ..; done } $ go_up 3 # go 3 directories up 回答2: I am not aware of any command that does that, but it is easy to create one yourself. For example, just add cdn() { for ((i=0;i<${1-0};i++)) do cd .. done } in your ~/.bashrc file, and after you create a new shell you can just run cdn N and you will move up by N directories 回答3: All

mysql system command

三世轮回 提交于 2019-12-10 11:19:38
问题 I am in MySQL and would like to change the current working directory. I tried to execute: mysql> system cd './my_dir' However, this does not seem to work. Has anyone run into a similar problem? 回答1: System is going to spawn a child process to run a shell command..... Current working directory is a process level property....so you can't change it in the parent from a child process. That's why it doesn't work. I briefly scanned the MySQL docs at http://dev.mysql.com/doc/refman/5.5/en/mysql

Identifying CDs

江枫思渺然 提交于 2019-12-09 00:38:11
问题 I'd like to be able to determine what music album CD is in a CD drive. For example, if someone claims that the CD in their drive is Eminem - The Eminem Show, I would like to be able to verify that the CD is indeed The Eminem Show. Any ideas? I've applied for a Gracenote developer license, but they won't get back to me for five days. Also, how does this work? Is there some GUID or other unique identifier that music discs are encoded with? Lastly, might this be possible with data CDs, like, say

Run two commands with a crontab

谁都会走 提交于 2019-12-08 15:29:45
问题 I have a quick question. I need to add a cron to my debain crontab using an automated shell script and I need the cron to do two things: cd into /etc/application run the command "scrapy crawl" crontab -l | { /bin/cat; /bin/echo "* 3 * * * cd /etc/application"; } | crontab - How do I get it to also run the scrapy crawl command? 回答1: You can have multiple commands in a single crontab line. Just separate them with semicolons: crontab -l | { /bin/cat; /bin/echo "* 3 * * * cd /etc/application ;

Unexpected behavior when nesting cd calls using Fabric

╄→尐↘猪︶ㄣ 提交于 2019-12-08 13:35:58
问题 I am experiencing some troubles with Fabric (version 1.7.0 on Ubuntu 13.04). Consider this function: def does_not_work(): with cd('/absolute/folder/one/'): with prefix('change_path_command'): with cd('/absolute/folder/two/'): run('some_random_command') I expect it to execute the same command as: def works(): run('cd /absolute/folder/one/ && change_path_command && cd /absolute/folder/two/ && some_random_command') However, here is the Fabric output of fab does_not_work : Requested: some_random

does cd command in a shell script load the rvmrc inside the destination directory?

☆樱花仙子☆ 提交于 2019-12-07 17:24:50
问题 when you have something like.. given inside projectx an .rvmrc file specifying ruby 1.9.2 and having two rubies on my system (ree-1.8.7 and ruby1.9.2) #!/bin/bash cd applications/projectx which ruby ruby -v the last two lines output ree-1.8.7 and its path which was not I intended to use. 回答1: Yes Rvm does define a wrapper around cd that looks like this: cd () { builtin cd "$@"; local result=$?; __rvm_project_rvmrc; __rvm_after_cd; return $result } It's difficult to tell why your .rvmrc isn't