curl: argument list too long

This is coming up because you are trying to pass the entirety of the base64’d content on the command line. curl has the ability to load in data to POST from a file, which I’d recommend doing. More information can be found in the man page, but the basic format is this: curl -X POST … Read more

Bash script: bad interpreter

The first line, #!/bin/bash, tells Linux where to find the interpreter. The script should also be executable with chmod +x script.sh, which it appears you did. It is highly likely that you created this file with a windows editor, which will place a <cr><lf> at the end of each line. This is the standard under … Read more

encoding of file shell script

I’d just use file -bi myfile.txt to determine the character encoding of a particular file. A solution with an external dependency but I suspect file is very common nowadays among all semi-modern distro’s. EDIT: As a response to Laurence Gonsalves’ comment: b is the option to be ‘brief’ (not include the filename) and i is … Read more

How do I download a file to a newly created directory with curl on OS X?

You could try using the –create-dirs argument which was added in curl 7.10.3: Here is an example that will create the directory hierarchy, (if it doesn’t already exist), and will name the subdirectory you require renamed with the output of the datecommand: curl -o /db-bkups/$(date +”%b-%d-%Y”)/timestamp-db.dump –create-dirs http://www.w3schools.com/xml/simple.xml The result is a file stored in … Read more

Awk to skip the blank lines

There are two approaches you can try to filter out lines: awk ‘NF’ data.txt and awk ‘length’ data.txt Just put these at the start of your command, i.e., awk -v variable=$bashvariable ‘NF { print variable … }’ myinfile or awk -v variable=$bashvariable ‘length { print variable … }’ myinfile Both of these act as gatekeepers/if-statements. … Read more