Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

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.

awk befehl mit Variablen funkt nicht ?

Empfohlene Antworten

Veröffentlicht

Hi @all,

kann mir das mal jemand erklären ?

Hab folgendes Problem, ich möcht mit awk die /etc/passwd auslesen, was eigetlich kein Prob

ist, aber so bald ich eine Varible benutzte, dann funktioniert das nicht ?!

Wenn ich es folgender maßen versuche dann funkt das nicht:

UID_MIN=500

UID_MAX=60000

awk -F: '$3>="$UID_MIN" && $3<="$UID_MAX" {print $1":"$5":"$7}' /etc/passwd | sort -n
Wenn ich es aber so versuche, dann geht es?!:
awk -F: '$3 >= "500"  && $3 <= "60000" {print $1":"$5":"$7}' /etc/passwd | sort -n

Hat jemand eine Ahnung wie ich das Prob lösen könnte ? Danke schon mal im voraus.

g_d_f

Das Problem sollten die " sein.

Setz das mal in ' um.

Hi, danke für dein post, leider kann das nicht funktioniren, weil '-Zeichen das $-Zeichen Schützt und somit keine Variable übergeben wird, sondern $UID_MIN und $UID_MAX als String.

Danke für deine Hilfe

g_d_f

UID_MIN=500

UID_MAX=60000

awk -F: '$3>="'$UID_MIN'" && $3<="'$UID_MAX'" {print $1":"$5":"$7}' /etc/passwd | sort -n

oder awk die Variablen als Parameter übergeben und die dann innerhalb von awk parsen (RTFM)

awk -v UID_MIN=$UID_MIN -v UID_MAX=$UID_MAX -F: '$3>=UID_MIN && $3<=UID_MAX {print $1":"$5":"$7}' /etc/passwd|sort -n

Danke euch zwei, ihr habt mir sehr weiter geholfen ... ;)

gruß

g_d_f

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.