Portál AbcLinuxu, 31. července 2025 15:30
bash(0)> grep -r 500 var/log/httpd/access.log:69.16.40.148 - - [09/Jan/2017:22:34:33 +0100] "GET /pages/create HTTP/1.0" 500 3471 var/log/httpd/access.log:225.219.54.140 - - [09/Jan/2017:22:35:30 +0100] "GET /posts/foo?appID=xxxx HTTP/1.0" 500 2477 var/log/httpd/access.log.1:2.71.250.27 - - [09/Jan/2017:22:41:26 +0100] "GET /pages/create HTTP/1.0" 500 2477 README:# contain the string "500". Note that there are no bash(0)> grep -r 500 |sed 's/:.*//' README bash(0)> grep -rl 500 README bash(0)>
grep -lr 500a to se jim nelíbilo. Prošlo ale:
grep -l 500 *
You are officially a command line master, great job! Pěkné, na chvíli zabavilo.
for F in `find` ; do echo -n $F ; if [ -d "$F" ] ; then echo "/" ; elif [ -x "$F" ] ; then echo "*" ; elif [ -h "$F" ] ; then echo "@" ; else echo ; fi ; doneJe validní nebo ne? Ta stránka to nechce přijmout
ls -1F
a nic..
ls -aF
ls -a1FA mý řešení má jen navíc ".." adresář. P.S. Projde
echo './';echo '../';echo '.hidden-dir/';echo '.hidden-file';echo 'README';echo 'normal-file.dat';echo 'runthis.sh*';echo 'symlink-file.dat@'
bash(0)> cat <<< "hello world" Unknown Error :( bash(☠️)>Tak nevím.
bash(0)> echo "hello world" Unknown Error :(
# There are a mix of files in this directory # that start with letters and numbers. Print # the filenames (just the filenames) of all # files that start with a number recursively # in the current directory. #Za pomoci:
for i in `find . -type f -name '[0-9]*' -exec basename {} \;` ; do echo $i | grep -P "^\d"; done
Poradíte kde je chyba? Nechce mi to vzít :-/ Díky
find . -type f -name '[0-9]*' | while read -r i; do basename "$i"; done
xargs
(přes rouru se mu předávají parametry a on pro každý pouští zadaný příkaz).
Složitější věci se dají udělat tak, že si napíšeš funkci, tu vyexportuješ a pak ji v xargs
spustíš pomocí bash -c
(příklad).
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.