I started an online Unix course. I entered the course kinda late and I'm having a little trouble getting caught up. We had a homework question (I got it wrong) it said to:
Change the current working directory to directory WT5 using a single command line and starting at the home path.
How in the world am I supposed to do that? I know how to change a directory from your current directory just $ cd WT5 And if I wanted to list all of the contents in the home directory I would use $ ls ~/nameofhomedirectory And, if I wanted to change the current working directory to the home directory I would use $ cd ~ or just $ cd
So how would I combine all of that in one single command line to change the current directory to another directory using a path that includes the home directory?
Thank you for all of your help in advance!
UPDATE: Okay. I can see now that this maybe a little confusing. So let me try to make it a little bit more clear where I am going wrong or getting mixed up.
Let's say this is a tree of directories you have.
Tree of Directories
Now, your home directory is user And your current working directory is work But you want to change your current working directory to play. How would you change the directory using a single command line and starting at your home direcotry and not your current working directory work
Thanks again!
I'm not quite sure I understand your question, but you could try:
cd ~/WT5
or:
cd $HOME/WT5
or if you absolutely need to be long-winded about it:
cd /user/homedirectory/subdirectory/currentworkingdirectory/WT5
These all include your home directory in the path. The short-hands are to be preferred.
This might do the trick:
cd ~/../users/carol/play
The idea is that you can go upwards from a home directory too.
Related
Writing a beginner shell script and it's asking for to locate and verify if a file under a specific name is located within my home directory but I'm not sure what command would best fit that.
To find any file in linux, use this command:
find . -name file_name
point means current directory
you can change it to /home/
thanks
I am having a problem with something seemingly very simple in Unix. I used the following code to move a file to another directory:
mv genes.gtf ./ ../..
The file is no longer in the original directory, but it has not shown up in the destination directory either! Has anyone experienced a similar thing before? What is causing the problem? Is it possible for it to take a while for a file to be moved, so it shows up in the destination directory with a big delay?
When 3 arguments are passed to mv, the first two are considered sources, and the last one is considered the destination. It seems you moved both genes.gtf and the current directory (./) to ../..
I think what you meant to write was mv genes.gtf ../..
As far as what happened to your file, I have no idea; I've never attempted to move ./ anywhere in unix/linux before.
Here's the scenario.
I am on the unix command line (in home directory). I want to browse the directory through
$ vim .
thus opening the vim netrw.
Now I am browsing the directory using the netrw.
What I want here is that when I exit vim netwr, I want my previous current working directory (in this example the home directory) to now become the directory I was previously in vim netrw.
Example:
step 1. now in home directory
step 2. vim . (thus opening vim netrw)
step 3. go to any directory (~/my/other/folders)
step 4. :q (to exit vim)
step 5. (here, I want my previous directory to now become ~/my/other/folders
any ideas on how to do it? I was thinking of doing something in .vimrc but I dunno how. Been into google search, but found nothing valuable.
A possible solution would be to change the current work directory while in netrw by pressing c, and spawn a new shell from the folder you're in by issuing :shell
So it would look like:
vim .
Navigate to the desired folder...
c
:shell
And there you are in a shell in the current folder you were in netrw.
And when you exit that shell, you fall back to where you were in netrw and can continue using the explorer.
I don't think it's possible at all. Every command executed via system('command') or :!command is executed through a subshell, not through the shell that started Vim so I don't see how you could alter the host shell in any way.
But I smell an XY problem here. What is your goal?
Do you want to be able to execute some commands on the files you just edited and you want to be in their directory? If so, do you know about :sh? :!command?
Do you want a "graphical" file explorer for your shell? If so, do you know vifm? Ranger? Midnight Commander?
To add to Wadih's answer, you can put this in your .vimrc file:
let g:netrw_keepdir=0
This means the working directory will be automatically updated and you don't need to press c each time.
So after navigating to a folder in netrw, all you need to do is do this:
:sh
And this opens the terminal in the current folder.
From the netrw help file:
By default, g:netrw_keepdir is 1. This setting means that the current
directory will not track the browsing directory. (done for backwards
compatibility with v6's file explorer).
Setting g:netrw_keepdir to 0 tells netrw to make vim's current directory
track netrw's browsing directory.
I'm trying to change the permissions of a few files that are used with a webpage I'm uploading to my site. I'm using the Unix command line to do it.
I've tried two commands:
chmod 755 index.html
chmod 644 index.html
But I get the message
chmod: WARNING: can't access index.html
after using these commands for some reason, and I have no idea why... initially I though it might be because I had the file open in a couple of programs (text editor and web browser), but I've closed these down, and I'm still getting the same problem... any idea why, and how I can set the permissions correctly so that the file will be viewable by anyone on the web, but only editable by me?
Cheers!
Here's a link that looks similar to your problem but it's on Solaris:
http://www.unix.com/solaris/45229-unable-chmod-file-directory.html
The solution is on pg 2 of this thread but the Cliff's note version of the solution is the person found that something else was mounting at that directory. It showed up when they ran
df -k /their_dir_location
Hope this helps.
another possible issue is ... if you are using solaris zones .. the directory visiable in more than one zone but only one zone has write abilities.
can you help me a little bit with the Terminal?
i would like to use these command lines :
cd /path/to/Qt
./configure -static <other parameters>
make sub-src
so i open the Terminal, and write cd then i drag QtSDK and it shows me this path : /Developer/Applications/Qt
EDIT :
so i guess the 3 lines must be copied one after the other...
i wrote those lines in a row, but this time i've got no error message, nor any responses if i try to write "-help" just after ./configure , as if it wasn't working. I'm following this tutorial from the doc : http://doc.qt.io/qt-5/osx-deployment.html
Any idea?
Im not sure what youre trying to do. Write a script to do it for you. her is a little bit of help.
if you type
pwd
it will return your current location. This way you can find out where you are.
Users/Paul/QtSDK
if the above is your goal,
pwd
should return
/Users/Paul
This means, to Change directory (cd), all you have to do is
cd QtSDK
This is assuming QtSDK is located in your user folder.
you can do
ls
to find out.
The following is the output of my ls in my home directory or "/Users/cy/
#:~ cy$ pwd
/Users/cy
#:~ cy$ ls
Desktop Downloads Movies Pictures Sites
Documents Library Music Public
You should also see your QtSDK folder there.
To restart your location, go back to where it should begin. Type:
cd
with nothing else.
this will put you back to your home folder..
Last but not least,
<Other Prams>
should be replace with the actual prams and not to be left as you have shown in your code
PS:Capitalization is important