Skip to main content

Questions tagged [for]

A tag to denote any questions relating to for loops

0 votes
1 answer
63 views

How to batch compress pdfs?

I'm looking to batch compress some pdfs, using the convert to/from ps trick outlined elsewhere. I have a function defined in an .zshrc file: function pdfcompress() { for f in "$1"; do ...
sporkl's user avatar
  • 103
0 votes
1 answer
25 views

terraform resource dependency with count(loop)

I'm trying to create stack of multiple vms on KVM_HOST with terraform. The catch is, I'm using pxeboot & kickstart to do installation. Kickstart file needs to carry some dynamic information, like ...
Sollosa's user avatar
  • 1,983
2 votes
1 answer
163 views

Not working break in for loop in bash script for mounting a VHD

I'm not an experienced programmer. So maybe it's obvious for you why the break command in this script does not terminate the loop, but I can't see what is causing the problem. I want to use the script ...
Shakesbeer's user avatar
0 votes
1 answer
58 views

using a variable which has content separated by spaces in shell in a for loop

I am trying to read a variable with spaces on prompt and trying to use in a for loop., For example: Enter the items to read separated by space... apple orange kiwi read items for i in "$...
sabarish tr's user avatar
-1 votes
1 answer
65 views

Output of loop variable shows different value than expected

Imagine I have two folders in my current working directory: back/ and front/. I am trying to enter inside each of them and do some stuff. From the simple script below: for dir in */ ; do echo &...
Rigel F. do C.'s user avatar
-3 votes
4 answers
167 views

How to catch all lines of a repeating pattern and do some actions with the subresults

I am looking for a possibility to catch in a repeating text pattern all variable amount of lines between them and then do an action with it in bash. Example text: Total: text1 text2 Total: text3 Total:...
André Letterer's user avatar
4 votes
2 answers
445 views

SSH for loop: parameter passed to function captured in variable is not expanded

I have several servers which have several files with deploy date info I need to parse, and get a local copy of the files which are 2 months old or older. #!/bin/bash # split on new line not space # ...
Nickotine's user avatar
  • 554
0 votes
2 answers
251 views

How to run for loop over SSH on remote so that variables expand?

If I ls files without a for loop in a remote host everything is fine however, if I capture the ls in a variable and try to echo each file it fails as the variables don't expand/have a value. What I ...
Nickotine's user avatar
  • 554
3 votes
2 answers
2k views

How to extract and delete contents of a zip archive simultaneously?

I want to download and extract a large zip archive (>180 GB) containing multiple small files of a single file format onto an SSD, but I don't have enough storage for both the zip archive and the ...
Kumaresh Balaji Sundararajan's user avatar
0 votes
2 answers
280 views

Pass multiple arguments from single line from a text file to teminal

I have a python program that requires 2 arguments input-file and output-file. It reads input-file and creates a copy of that file with some modifications in the output-file. I created a text file with ...
Data Engineer's user avatar
1 vote
2 answers
2k views

Is there a syntax for a "for" loop over words or lines in a variable, that will work unmofdified in both bourne shell and zsh?

I have a variable that contains a list of strings, one per line, to be looped over in a for...in...do...done command. I move regularly between bourne shell and zsh. As far as I can understand it, zsh ...
Stilez's user avatar
  • 1,291
0 votes
1 answer
850 views

Recursively fix corrupted video files with ffmpeg

I think I'm pretty close to having a code which will start at a directory, then spit out a fixed copy, using fd (instead of find) and ffmpeg. I have written the if statement here as psudo-code: for i ...
1toneboy's user avatar
  • 465
0 votes
3 answers
712 views

for loop through multiple directories and multiple files

I want to check if each .bam file is accompanied with a .bai file. So if clean_xyz_1.sorted.bam is present clean_xyx_1.sorted.bam.bai should also be present. Each file has a variable string in the ...
user3637557's user avatar
0 votes
2 answers
127 views

For loop with Multiple IF condition's in Shell scripting

Firstly , In the /tmp/test file path I have the below directories amb bmb cmb By running the find command, I am getting the below list of files inside these three directories: amb/eng/canon.amb bmb/...
afrin's user avatar
  • 71
1 vote
0 answers
32 views

Do I have to write a shell script purely to access bash for loops inside of say watch? [duplicate]

I'd like to monitor apps that have inotify instance in real-time with watch using something similar to: watch "for foo in /proc/*/fd/*; do readlink -f $foo; done | grep inotify | sort | uniq -c | ...
Tomachi's user avatar
  • 111

15 30 50 per page
1
2 3 4 5
31