Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with basic scripting error

Featured Replies

I hope this is the right place to ask this ...

I'm not new to scripting but definitely out of practice by about 20 years.

I've written a half decent BASH script to rsync two unRAID 6 servers on a disk by disk basis.

I can make this work for one disk or for all disks, using 'case' statements.

However, I want to extend this to selecting multiple disks (thus permitting me to skip certain disks) using this line:

 

#DEV version:-

#for i in `ls -d /mnt/d*|grep -v disks|grep -E '$disknum'`; do find $i -maxdepth 1 -not -empty -type d|grep -vx $i;done > /boot/scripts/syncup.list

 

I'm obviously passing 'disknum' via a $n Argument

 

I can make this work on the command line using " grep -E  'a|b|c' "  ...  but I can't seem to get it working within my script. My issue seems to be my inability to pass this string < 'a|b|c' > via a variable into the grep syntax such as " grep -E $list ".

Here's my simple test which replicates what I can/can't do:

 

--------------------------------------

user@svr1:/boot/scripts/dev# cat testlist

1

2

3

4

5

6

7

8

9

10

11

12

 

user@svr1:/boot/scripts/dev# cat testlist|grep -E '2|8'                   

2

8

12

 

Success !

... but if I try and pass it as a variable I get ...

user@svr1:/boot/scripts/dev# list="'2|8'";echo $list;cat testlist|grep -E $list

'2|8'

--------------------------------------

The last line echo's the correct value ... but causes the above test script to just ends as shown.

I've tried other combinations of parentheses but it generally error's out such as:

 

-bash: 2|8: command not found

Usage: grep [OPTION]... PATTERN [FILE]...

Try 'grep --help' for more information.

 

Any ideas/suggestions anyone ? 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.