我正在学习这个剧本,我想知道cat本节的内容.
if cat downloaded.txt | grep "$count" >/dev/null
then
echo "File already downloaded!"
else
echo $count >> downloaded.txt
cat $count | egrep -o "http://server.*(png|jpg|gif)" | nice -n -20 wget --no-dns-cache -4 --tries=2 --keep-session-cookies --load-cookies=cookies.txt --referer=http://server.com/wallpaper/$number -i -
rm $count
fi
Run Code Online (Sandbox Code Playgroud)
像大多数猫一样,这是一只无用的猫.
代替:
if cat downloaded.txt | grep "$count" >/dev/null
Run Code Online (Sandbox Code Playgroud)
它原本可以写成:
if grep "$count" download.txt > /dev/null
Run Code Online (Sandbox Code Playgroud)
实际上,因为您已经消除了管道,所以您已经消除了if语句处理的退出值的问题.
你会看到的大多数Unix猫都是无用的.然而,人们喜欢猫几乎和使用grep/ awkpipe 一样多,或者使用多个grep或sed命令而不是将所有内容组合到一个命令中.
该cat命令代表concatenate允许您连接文件.它被创建用于split将文件分成多个部分的命令.如果你有一个非常大的文件,但是必须把它放在无法容纳整个文件的软盘上,这很有用:
split -b140K -a4 my_really_big_file.txt my_smaller_files.txt.
Run Code Online (Sandbox Code Playgroud)
现在,我要my_smaller_files.txt.aaaa和my_smaller_files.txt.aaab等等.我可以把它们放在软盘上,然后放在另一台电脑上.(哎呀,我可能会全力以赴,并在你身上使用UUCP!).
一旦我在另一台计算机上获取文件,我就可以这样做:
cat my_smaller_files.txt.* > my_really_big_file.txt
Run Code Online (Sandbox Code Playgroud)
而且,这是一只没有用的猫.