![]() |
Hallo und herzlich Willkommen aus den Vereinigten Staaten, die UNIX-und Linux-Foren! Vielen Dank für Ihren Besuch und die Teilnahme an unserem Global Community.
|
|
Google unix.com
|
|||||||
| Foren | Registrieren | Forum-Regeln | Links | Alben | FAQ | Benutzerliste | Kalender | Suche | Die heutige Beiträge | Alle Foren als gelesen markieren |
| UNIX for Dummies Questions & Answers Wenn Sie nicht sicher sind, wo Sie eine UNIX-oder Linux-Frage, post it here. Alle UNIX-und Linux-Anfänger willkommen! |
Mehr UNIX-und Linux-Forum Themen Vielleicht finden Sie hilfreiche
|
||||
| Faden | Thread Starter | Forum | Antworten | Last Post |
| jar-Befehl nicht erkannt | orahi001 | UNIX for Dummies Questions & Answers | 1 | 05-06-2008 11:29 AM |
| Abrufen 5. Letzte Feld zu Feld! | jobbyjoseph | UNIX for Dummies Questions & Answers | 3 | 05-16-2007 04:20 AM |
| Beweglicher Teil eines Feldes zu einem anderen Feld mit AWK | rjsha1 | Shell Programmierung und Scripting | 5 | 08-04-2006 06:39 AM |
| Ich bin nicht erkannt | Hilfe | Forum Support-Bereich für Besucher & Account Probleme | 0 | 01-10-2006 04:30 AM |
| Argument nicht als integer | scmay | Shell Programmierung und Scripting | 1 | 05-14-2004 03:41 AM |
![]() |
|
|
LinkBack | Thread Tools | Suche diesen Thread | Rate Thread | Anzeige-Modi |
|
|
|
||||
|
Hi,
Ich schreibe ein Skript zu verwenden awk, um eine Reihe von CP-Kommandos aus einer Eingabedatei ABC. abc-Datei: / data / a.dbf / data / Juni / b.dbf gewünschte Ausgabe: cp --pr a.dbf / data / a.dbf cp --pr b.dbf / data / Juni / b.dbf Skript: $ Cat abc | awk '(print "cp --pr "` basename $ 1 `" "$ 1) ' Ich habe versucht, mit Einsatz awk basename Befehl, aber es scheint, dass das Feld $ 1 in backquotes wird nicht erkannt von awk. Wie man dies beheben kann? Vielen Dank, voa2mp3 |
|
|||||
|
Hi.
Zitat:
Code:
#!/usr/bin/env sh
# @(#) a1 Demonstrate awk feature "command | getline".
set -o nounset
echo
## Use local command version for the commands in this demonstration.
echo "(Versions of codes used in this script -- local code \"version\")"
version bash awk
echo
awk '
{ command = "basename " $1
command | getline file
print "cp -pr " file " " $1 }
' data1
exit 0
Code:
% ./a1 (Versions of codes used in this script -- local code "version") GNU bash, version 2.05b.0(1)-release (i386-pc-linux-gnu) GNU Awk 3.1.4 cp -pr a.dbf /data/a.dbf cp -pr b.dbf /data/june/b.dbf |
|
|||||
|
Einige andere Arten
![]() Code:
% set -- $(<file)
% paste -d" " <(printf "cp -pr %s\n" "${@##*/}") <(printf "%s\n" "$@")
cp -pr a.dbf /data/a.dbf
cp -pr b.dbf /data/june/b.dbf
Code:
zsh 4.3.4% <file while IFS= read;do print -r "cp -pr $REPLY:t $REPLY";done cp -pr a.dbf /data/a.dbf cp -pr b.dbf /data/june/b.dbf Code:
zsh 4.3.4% awk '$0="cp -pr "$NF" "$0' FS="/" file cp -pr a.dbf /data/a.dbf cp -pr b.dbf /data/june/b.dbf |
![]() |
| Lesezeichen |
| Tags |
| Linux-Befehle |
| Thread Tools | Suche diesen Thread |
| Anzeige-Modi | Rate this thread |
|
|