tarring a file with shell not working [closed] - shell

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
I'm trying to tar a two files into one, so I have this:
tar -zcvfW "${DATADIR}daily_data_files/LeveL_EOD_VOL_${1}.tar.gz" -C "${DATADIR}temp/LeveL_EOD_VOL_*_${1}.csv" >> "${DATADIR}temp/email.log"
However, I'm getting these errors:
tar: Removing leading '/' from member names
tar: /var/www/vhosts/levelats/data/daily_data_files/LeveL_EOD_VOL_20110121.tar.gz: Cannot stat: No such file or directory
tar: LeveL_EOD_VOL_*_20110121.csv: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
I'm not sure why the tar isn't getting created, is it because it can't find the two Level_EOD files? Is the wildcard(*) wrong?

I think what is happening is that the -C option is trying to change directory into the first directory expanded by your glob pattern; I think you want:
tar -zcvfW "${DATADIR}daily_data_files/LeveL_EOD_VOL_${1}.tar.gz" -C "${DATADIR}temp/" "LeveL_EOD_VOL_\*_${1}.csv" >> "${DATADIR}temp/email.log"
Note that I split the -C option from the list of CSV files that comes after it.

The order of the option flags is significant (at least the f needs to precede the filename). Try changing from -zcvfW to -zcvWf.
Also -C takes a directory as an argument.

Related

Cannot open tar file [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I have a file called data. Although the file doesn't have an extension, I used the file bash command to see what type of file it is:
$ file data
data: POSIX tar archive (GNU)
Seeing as it is a tar file, I try to open it but I get an error:
$tar xvf data
tar: data: Not found in archive
You need to add a hyphen before the xvf.
tar -xvf data
Else, if you are in another location.
tar -xvf /<path to data>/data

bash LS command giving hidden folders in output [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am not sure when this behavior started but by typing the ls command, I am getting the following output:
$ls
./ ../ .DS_Store Books/
I am not very sure about the first three items and they always come in every folder. Can anyone explain me how to get rid of them? I am using OS X Yosemite
The first two: ./ and ../ are current directory and parent directory respectively. You can't get rid of them. The last one .DS_Store is probably some config file/directory which you can remove with:
rm -f .DS_Store # use -r if it's a directory
But be sure to check what's its for!
The bahaviour of ls is not the reason for the "extra" output. You probably have an alias something like:
alias ls='ls -a'
in your shell. To find out exactly what it's aliased to, do:
type ls

Bash - wait for a process (here gcc) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
On my Ubuntu machine I want to create a custom command for compiling a c file.
At the moment I have something liks this which does not work like I want to:
#compile the file
gcc $1 -o ~/.compile-c-output
#run the program
./~/.compile-c-output
#delete the output file
rm ~/.compile-c-output
The problem is that the run command is executed before gcc is ready and so the file does not exist. How can I wait until gcc is ready and I can run the file normaly?
Btw how can I add a random number to the output file so this script also works if I run it on two different terminals?
./~/.compile-c-output
Get rid of the leading ./. That's why the file doesn't exist.
~/.compile-c-output
To get a random file name, use mktemp. mktemp guarantees not to overwrite existing files.
file=$(mktemp) # unspecified file name in /tmp
gcc "$1" "$file" && "$file"
rm "$file"

Is this a bug in the Bash shell [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Have I found a bug in bash?
I have created a folder named Test
cd Test/
rm -rf ../Test (Deleted the PWD while I was in that directory, as shown in image)
Not a bug, not related to bash either. You're current working directory (and all the environment variables that hold the path info in your shell) is simply pointing to a filesystem node that's been orphaned. Listing it will give you what's in the node, which is nothing because . and .. are gone (because it's orphaned). Note that rm removes everything in the directory before orphaning the node. Thus, ls gives you nothing.
Also note that when you try to create a file while inside the deleted directory with something like touch blah or mkdir blah, it'll give you a file not found error.
"orphaned" may not be the correct term, I'm simply using it to mean that it has no parent node.

What's the difference between directory contents and directory entries? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
The manpage for the ls command says that:
-d, --directorylist
directory entries instead of contents.
So, what's the difference between directory contents and entries? The ls -d command in my home directory only shows:
.
What's the purpose of the -d option of ls command?
In my experience, the -d flag is most useful when you run ls with a wild card.
In a command such as ls -l "B*" if a directory is matched, then ls will list the contents of that directory. This is obnoxious if you don't care about the contents of the subdirectories.
For example, suppose your directory structure is as follows:
/tmp/Foo
|-Bar
|---FooBar
|-Buzz
|-FizzBuzz
ls "/tmp/Foo/B*" will produce the following:
/tmp/Foo/Buzz
/tmp/Foo/Bar:
Foobar
ls -d "/tmp/Foo/B*" will produce the following:
/tmp/Foo/Buzz
/tmp/Foo/Bar
Notice that the second case is almost certainly what was intended.
If you do ls -l, you will get the info for all the items ( contents) under (current) directory. But what if you wanted to see the info for the (current) directory? That is when you do ls -ld
Of course, since ls just prints the names of the contents, ls -d prints . ( or the directory name if given path) and seems useless.
You can also do ls -d */ to list only the directories.
-d, --directorylist
directory entries instead of contents.
It simply means that the whatever information/entries is available about the directory would be displayed (and not its contents).

Resources