How to untar without leading slash / - tar

I have tar file, 11.2.0.4.tar, of the following path: /oracle/product/11.2.0.4. I want to untar it in a custom folder, for example /export. I tried with the -C option, but didn't work - the shell hangs for a few seconds, then the prompt is returned without any result.
tar -xvf 11.2.0.4.tar -C /export
So, how do I extract without the "/" so I would have /export/oracle/product/11.2.0.4? I read there is an option only when taring, but not when untaring.

Related

Forked docker image not building

I am trying to fork this docker image so that if anything changes on the original it won't affect me.
I have forked the repo corresponding to that image to my own repo.
I have cloned the repo and am trying to build it:
docker build . -t davcal/gcc-cross-x86_64-elf
I am getting this error:
+ cd /usr/local/src
+ ./build-binutils.sh 2.31.1
/bin/sh: 1: ./build-binutils.sh: not found
The command '/bin/sh -c set -x && cd /usr/local/src && ./build-binutils.sh ${BINUTILS_VERSION} && ./build-gcc.sh ${GCC_VERSION}' returned a non-zero code: 127
What makes no sense to me is that if I use the original image, it builds successfully:
FROM randomdude/gcc-cross-x86_64-elf
...
Maybe Docker Hub stores a pre-built image?
How do I fix this?
Note: I am using Windows. This shouldn't make a difference since the error originates within the container.
Edit
I tried patching the Dockerfile to chmod executable permissions to the sh files in case that was causing problems on Windows. Unfortunately, the exact same error occurs.
RUN set -x \
&& chmod +x /usr/local/src/build-binutils.sh \
&& chmod +x /usr/local/src/build-gcc.sh \
&& cd /usr/local/src \
&& ./build-binutils.sh ${BINUTILS_VERSION} \
&& ./build-gcc.sh ${GCC_VERSION}
Edit 2
Following this method, I inspected the container to see if the sh files actually exist. Here is the output.
I ran docker run --rm -it c53693f11514 bash, including the hash of the intermediate container of the previous successful step of the Dockerfile.
This is the output showing that the files do exist:
root#9b8a64ac2090:/# cd usr/local/src
root#9b8a64ac2090:/usr/local/src# ls
binutils-2.31.1 build-binutils.sh build-gcc.sh gcc-8.2.0
From the described symptoms, file exists, is a shell script, and works on other machines, the "file not found" error is most likely from Winidows linefeeds being added to the file. When the Linux kernel processes a shell script, it looks at the first line, the #!/bin/sh or similar, and then finds that interpreter to run the shell script. If that interpreter isn't found, you'll get a "file not found" error.
In this case, the file it's looking for won't be /bin/sh, but instead /bin/sh\r or /bin/sh^M depending on how you want to represent the carriage return character. You can fix that for single files with a tool like dos2unix but in general, you'll want to fix git itself since there are likely other files that have had their linefeeds corrupted. For details on adjusting the behavior of git, see this post.

tar command Option Not able to understand

Check the Size of the tar, tar.gz and tar.bz2 Archive File.
To check the size of any tar, tar.gz and tar.bz2 archive file, use the following command. For example the below command will display the size of archive file in Kilobytes (KB).
tar -czf - tecmint-14-09-12.tar | wc -c
12820480
tar -czf - MyImages-14-09-12.tar.gz | wc -c
112640
tar -czf - Phpfiles-org.tar.bz2 | wc -c
20480
What does " - " do in this Command not able to find anything related to it in Official tar Documentation : ref 18
- is the option value for the -f option, which is the filename of the output file, normally a tgz filename.
- is special in that many tools accept it as an alias for stdout, which is in this case a pipe to wc -c. Remove the wc and you'll see it "messes up" your terminal
PS: it seems not documented in the tar man page, imo it should.

Tar doesen't extract with -P flag

I have an archive named compressed.tar.gz
I want to exract its contents to the folder uncompressed, located in the same directory.
In terminal:
tar -xf compressed.tar.gz -C uncompressed
This works and extracts correctly, however I get an stderror: "Removing leading "/" from member names". I've running above command using -P to suppress the error message as so:
tar -Pxf compressed.tar.gz -C uncompressed
Although the contents are not being extracted at all to uncompressed folder. Any ideas would be greatly appreciated.

How to use Fred's ImageMagick textcleaner script?

I want to do OCR on some of my images, but images are not quite very impressive. So, for cleaning it I wanted to use Fred's ImageMagick Textcleaner script. Command that I gave:-
sh textcleaner.sh input_file output_file -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20
This is the arguments which Fred has given on website itself. I am also doing for same sample image. But I don't think so any of my options are working everything is by default. And I keep getting this error also
textcleaner.sh: line 177: type: textcleaner.sh: not found
usage: dirname path
usage: basename string [suffix]
basename [-a] [-s suffix] string [...]
And At last I had to keep the files in same folder where my textcleaner script is. How can I make it global and give the absolute path to it rather than putting the files wherever textcleaner is.
It's a bash script - it says so in the first line - yet you are trying to run it in sh - which is not bash. You need to make the script executable, by running
chmod +x textcleaner
then you can run it properly using:
./textcleaner ... arguments ...
That should make the error message go away. Then try showing us a sample image so we can try and see what the problem is.
In my ImageMagick scripts, the syntax is script name ...arguments... input output. So your command should be
bash textcleaner.sh -g -e stretch -f 25 -o 20 -t 30 -u -s 1 -T -p 20 input_file output_file
See my Pointers For Use (for further configuration) at my home page: http://www.fmwconcepts.com/imagemagick/index.php

Piping shasum to grep, but grep returning all lines of piped input, even ones that don't match

I'm trying to script the download of the node.js source and corresponding SHASUMS256.txt, checksum it, grep for OK, and return no results just exit code 0 on success using grep's -q flag:
wget http://nodejs.org/dist/latest/node-v0.10.26.tar.gz
wget http://nodejs.org/dist/latest/SHASUMS256.txt
sha256sum -c SHASUMS256.txt|grep -q OK
However, grep is returning a selection of the non-matching lines "no such file or directory" errors (though not all, confusingly):
> sha256sum -c SHASUMS256.txt|grep -q OK
sha256sum: node-v0.10.26-darwin-x64.tar.gz: No such file or directory
sha256sum: node-v0.10.26-darwin-x86.tar.gz: No such file or directory
sha256sum: node-v0.10.26-linux-x64.tar.gz: No such file or directory
sha256sum: node-v0.10.26-linux-x86.tar.gz: No such file or directory
sha256sum: node-v0.10.26-sunos-x64.tar.gz: No such file or directory
sha256sum: node-v0.10.26-sunos-x86.tar.gz: No such file or directory
sha256sum: node-v0.10.26-x86.msi: No such file or directory
sha256sum: node-v0.10.26.pkg: No such file or directory
sha256sum: node.exe: No such file or directory
Any idea what the problem is here? All I want from this script is return code 0 if the checksum succeeds (eg grep matches OK), or return code non-0 if it fails.
When you pipe the output of a command as input to other command, only stdout of first command is passed as stdin to the second command.
The lines you see are sent by the sha256sum program to stderr.
You can verify that by sending stderr of sha256sum command also to grep by
sha256sum -c SHASUMS256.txt 2>&1 |grep -q OK
Hope that helps.

Resources