I have a file (reviews_dataset.tar.gz) that contains many files which contains data. I am required to extract the files in this archive and then perform some basic commands on the file. So far I have created a directory named (CW) and found a command tar zxvf fileNameHere.tgz
but when I run this it of course cannot find my file as I have not "downloaded it" into my directory yet? How do I get this file into my directory so that I can then extract it? Sorry if this is poorly worded I am extremely new to this.
Asked
Active
Viewed 8,455 times
0

Charles Duffy
- 280,126
- 43
- 390
- 441

John Smith
- 679
- 1
- 9
- 17
-
This question has nothing at all to do with either putty (as the terminal has nothing at all to do with which commands are or aren't available on the remote OS) *or* bash (none of the commands in question are bash-specific; they'd work with any UNIX shell). – Charles Duffy Feb 15 '16 at 22:51
-
...nor is it a question about software development, which means that it's a better fit for SuperUser than StackOverflow. – Charles Duffy Feb 15 '16 at 22:52
2 Answers
1
You must either run the command from the directory your file exists in, or provide a relative or absolute path to the file. Let's do the latter:
cd /home/jsmith
mkdir cw
cd cw
tar zxvf /home/jsmith/Downloads/fileNameHere.tgz

paddy
- 60,864
- 6
- 61
- 103
-
Thank you, I thought to do this but I am using a server provided by my uni and I cant seem to get into the same document system as the one that PuTTY is using so cannot download my tar.gz file to a "findable" directory? – John Smith Feb 14 '16 at 22:45
-
Where does the file live? Is it on your _local_ machine? Which machine is PuTTY connecting to? You must at least have the file on the same machine or accessible through a share. That's out of scope for this question. There are many ways to do it, but it depends on a lot of things. – paddy Feb 14 '16 at 22:47
-
The file is downloaded on my local machine where as putty is connecting to my uni account files I think? – John Smith Feb 14 '16 at 22:58
-
Are you required to have it on your Uni server, or do you just want to extract the files on your local machine? Maybe [this question](http://stackoverflow.com/q/21587036/1553090) will help you. – paddy Feb 14 '16 at 23:00
-
Is there a way to make it so that PuTTY uses the directories on my local machine? – John Smith Feb 14 '16 at 23:01
-
I am not required to have it on my uni server but the only "Host Name" I have is the one through my uni – John Smith Feb 14 '16 at 23:02
-
No. PuTTY is a _client_. It is facilitating a terminal connection to another machine and allowing you to interact. It has nothing to do with your file system. I don't understand the comment you just made. In any case, if you don't need to extract them on the remote machine, just install 7-Zip. It can extract gzipped tarballs. – paddy Feb 14 '16 at 23:04
0
You should use the command with the options preceded by dash like this:
tar -zxvf filename.tar.gz
If you want to specify the directory to save all the files use -C:
tar -zxf filename.tar.gz -C /root/Desktop/folder

Daniel Martín
- 117
- 6