Home / PC Gaming / Hardware / Store / Discord

For while Loops and things


#1

Howdy,

So I’m wanting to write a bash script that utilizes two for while loops and allows a user to enter in numbers between 1 and 100 and then enter directories they’d like to search and then what they want to search for.

I already have the two for loops created, so i need help to add them to a bash script.

Loop #1:

for i in `seq 1 10`;do zgrep "bar" /foobar/foo.$i.txt; done

Loop #2:

for o in `seq -w 1 10`;do zgrep "bar" /foobar$o/foo.$i.txt; done

I have the begins of the script here:

#!/bin/bash
for o in `seq -w 1 10`;do zgrep "bar" /foobar$o/foo.$i.txt; done
do

  for i in `seq 1 10`;do zgrep "bar" /foobar$o/foo.$i.txt; done
    do
          zgrep -P "$var$0$var2$i"
    done

I think i could work this out on my own but thought I’d ask the community.


#2

Why not just use dirs?

https://www.linuxjournal.com/node/1002351