(_ is input, i think) Answer Escape the grave accent. It’s special to the shell and is one way (the archaic one) to do command substitution. As noted by @dave_thompson_085 an alternative is to use single quotes in lieu of the double quotes you used, or to specify the hexadecimal representation of the gr…
Tag: sh
aws cli describe cluster error using ‘for loop’
I’m having trouble trying to run a for loop with the aws cli command aws eks describe-cluster. I receive the below error on execution. My scripting is not the best. Any help would be greatly appreciated. Thanks. If I simply run aws eks list-clusters | grep dev-shark it outputs the below: It seems to be …
How do I copy first 3 lines and last 2 lines of a file, and create new file [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 …
How to introduce an input in a C program through shell script?
When I execute the program in console I just do this: and it just print a integer. The thing here is that I want to introduce 1000 textfiles as input so I made this script: The trouble here is that the script is not putting the output in the file text because is not iterating as it should, I think
Split/Slice large JSON using jq
Would like to SLICE a huge json file ~20GB into smaller chunk of data based on array size (10000/50000 etc).. Input: Currently running in a loop to get the desire output by incrementing x/y value, but performance is very slow and takes very 8-20 seconds for a iteration depends on size of the file to complete …
Getting bad substitution error in shell script
I have a variable COUNTRY=”INDIA” and another sets of variables:- INDIA_POPULATION=”5,00,00,000″, CHINA_POPULATION=”6,00,00,000″. In script I am trying to call them using command:- echo ${ ${COUNTRY}_POPULATION } But I am getting bad substitution error. Can someone please t…
Shell script ‘read’ doesnt work with ‘EOF’
This script below is working, I want to read a value from files svc1.data and used it in syntax. But this script below doesn’t work, it keeps saying : -bash: syntax error near unexpected token `;’ Please help, whats wrong with the 2nd script.. Answer Just close the HEREDOC, like this:
Linux Shell Script – Mounting and Backing Up Files
I’m writing my first shell script. I want to check if a filesystem is mounted. If so, then backup the documents from my main drive to the backup that is mounted. If not, mount the filesystem, then backup the documents. I executed the script, yet all I got was a lot of text. It didn’t perform as I …
How to count all the files using ls -l statements separated by && in a single line?
I’m tyring to count all the files from several ls -l statements for certain file types separated by the double amperand symbol like so: The technique I’ve seen for a single file type or all files will simply count all the end of line characters it finds using an egrep command: egrep -c ‘^-&#…
Dockerfile – can’t unzip files using a shell script
I’m facing an issue unziping files that have been copied on a docker image. I tried using the RUN unzip /file.zip and other techniques that I came across but nothing seems to work. So then I tried adding the unziping action into the a shell script that I use as entrypoint for my docker image. Here is th…