Shell script “for” loop syntax

Brace expansion, {x..y} is performed before other expansions, so you cannot use that for variable length sequences. Instead, use the seq 2 $max method as user mob stated. So, for your example it would be: max=10 for i in `seq 2 $max` do echo “$i” done

Subtract two variables in Bash

Try this Bash syntax instead of trying to use an external program expr: count=$((FIRSTV-SECONDV)) BTW, the correct syntax of using expr is: count=$(expr $FIRSTV – $SECONDV) But keep in mind using expr is going to be slower than the internal Bash syntax I provided above.

docker entrypoint running bash script gets “permission denied”

“Permission denied” prevents your script from being invoked at all. Thus, the only syntax that could be possibly pertinent is that of the first line (the “shebang”), which should look like #!/usr/bin/env bash, or #!/bin/bash, or similar depending on your target’s filesystem layout. Most likely the filesystem permissions not being set to allow execute. It’s … Read more

How to create a link to a directory on linux [closed]

Symbolic or soft link (files or directories, more flexible and self documenting) # Source Link ln -s /home/jake/doc/test/2000/something /home/jake/xxx Hard link (files only, less flexible and not self documenting) # Source Link ln /home/jake/doc/test/2000/something /home/jake/xxx More information: man ln /home/jake/xxx is like a new directory. To avoid “is not a directory: No such file or … Read more

How to expand a CMD shell variable twice (recursively)

Thinking in terms of a less tortuous solution, this, too, produces the CCC you desire. setlocal enabledelayedexpansion set AAA=BBB set BBB=CCC for /F %%a in (‘echo %AAA%’) do echo !%%a! edit: to dissect this answer: setlocal enabledelayedexpansion – this will allow for any environment variable setting during your bat to be used as modified during … Read more

What is the subprocess.Popen max length of the args parameter?

If you’re passing shell=False, then Cmd.exe does not come into play. On windows, subprocess will use the CreateProcess function from Win32 API to create the new process. The documentation for this function states that the second argument (which is build by subprocess.list2cmdline) has a max length of 32,768 characters, including the Unicode terminating null character. … Read more

How to print 5 consecutive lines after a pattern in file using awk [duplicate]

Another way to do it in AWK: awk ‘/PATTERN/ {for(i=1; i<=5; i++) {getline; print}}’ inputfile in sed: sed -n ‘/PATTERN/{n;p;n;p;n;p;n;p;n;p}’ inputfile in GNU sed: sed -n ‘/PATTERN/,+7p’ inputfile or sed -n ‘1{x;s/.*/####/;x};/PATTERN/{:a;n;p;x;s/.//;ta;q}’ inputfile The # characters represent a counter. Use one fewer than the number of lines you want to output.