Saturday 15 August 2015

linux - A Shell script to find and cd into a folder taking a folder name as argument in one step -


I tried writing a liner in the bash,

  find ~ -name music- Type D-XAC CD '{}' \;   

This is getting with exec using one but I am getting the error:

Find: `cd ': No such file or directory

Try another with XARGS,

 Find <~> -name music-type d -print0 | Now again I tried to write a script. S  
  palette = $ (~ ~ -name $ 1 -type d | head - N 1) CD $ $ 

and the script < Code> ./ 1.sh music , and it does not work.

So far, the thing working is typing the following command directly into the terminal

  cd `find ~ -iname books -type d | Head-n1`   

Can someone help me by pointing out my mistake? I am trying to write a liner and later it has aka name.

Note: The script did not work to find results with just one result and no spaces.

I am using the console with Bash version 4.2.45 (2). p << div>

You will see cd in your current shell Should run. Run it in another shell, as you have seen, will not work. Create a function example:

  mycd () {cd "$ {1} foo"}    

No comments:

Post a Comment