English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The echo command in Shell is similar to the echo command in PHP, both of which are used for string output. Command format:
echo string
You can use echo to implement more complex output format control.
echo "It is a test"
The double quotes can be omitted here, the following command has the same effect as the above example:
echo It is a test
echo \
The result will be:
It is a test
يمكن أيضًا تجنب استخدام العلامات雙引
يقرأ الأمر read سطرًا من المدخل الاستاندارد، ويخصص قيمة كل حقل من هذا السطر لمتغير الشل
#!/bin/sh read name echo "$name It is a test"
يتم حفظ الكود أعلاه كـ test.sh، ويتلقى المتغير name المدخلات من المدخل الاستاندارد، النتيجة ستكون:
[root@www ~]# sh test.sh OK # مدخلات استاندارد OK It is a test # مخرجات
echo -e "OK! \n" # -e يفتح الترجمة echo "It is a test"
نتيجة الإخراج:
OK! It is a test
#!/bin/sh echo -e "OK! \c" # -e يفتح الترجمة \c لا يغير السطر echo "It is a test"
نتيجة الإخراج:
OK! It is a test
echo "It is a test" > myfile
echo '$name\"'
نتيجة الإخراج:
$name\"
echo `date`
ملاحظة: يستخدم هنا العلامة العكسية للأسهم `, وليس العلامة التشديد '.
سيتم عرض التاريخ الحالي
Thu Jul 24 10:08:46 CST 2018