منبع اصلی نوشتار زیر در این لینک قرار دارد

Explain Shell

اگر تا بحال با خط فرمان در توزیع های گنو/لینوکسی کار کرده باشید حتما از دستوراتی استفاده کرده‌اید که آشنایی قبلی با آن‌ها نداشته‌اید. کاربران معمولا در چنین مواقعی  به manual  آن دستور مراجعه می‌کنند. man هر دستور اطلاعات کامل و جزئیات زیادی را در اختیار کاربر قرار می‌دهد. اما روش‌ دیگری برای یافتن اطلاعات مربوط به دستورات بش وجود دارد. در ادامه قصد معرفی کدی را داریم که توسط آن می توانید اطلاعات خلاصه‌ شده‌ هر دستور را در محیط بش بدست آورید. این کد اطلاعات درخواستی را از اینترنت دریافت و برای کاربر به نمایش میگذارد. پس اتصال به اینترنت یکی از پیشنیاز‌های استفاده از این کد می‌باشد. برای استفاده از این کد به تنها بسته پیش‌نیازی که احتیاج دارید بسته curl می‌باشد که خوشبختانه در اکثر توزیع های امروزی این بسته به صورت پیشفرض نصب می‌باشد، اما در صورت نیاز آن را به این صورت نصب نمایید.

sudo apt-get install curl [On Debian systems]  
sudo pacman -Syu curl [On Arch  systems]

 در پایین کد را مشاهده میکنید.

# explain.sh begins
explain () {
  if [ "$#" -eq 0 ]; then
    while read  -p "Command: " cmd; do
      curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
    done
    echo "Bye!"
  elif [ "$#" -eq 1 ]; then
    curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
  else
    echo "Usage"
    echo "explain                  interactive mode."
    echo "explain 'cmd -o | ...'   one quoted command to explain it."
  fi
}

 یک ترمینال باز کنید و دستور زیر را اجرا نمایید.

nano .bashrc

 حالا کد بالا را به انتهای فایل باز شده اضافه کنید و برای ذخیره Ctrl+o و برای خروج Ctrl+x را بفشارید. حال در خط فرمان دستور Explain را اجرا کنید. خواهید دید برنامه منتظر دریافت نام دستورات از سمت کاربر خواهد بود. یکی از دستورات بش را وارد کنید و کلید اینتر را بفشارید. بسته به سرعت اینترنت توضیحات دستور مورد نظر در خروجی چاپ خواهد شد. امکان دریافت  راهنما برای دستورات ترکیبی نیز وجود دارد.

Command: nano

nano(1)
  nano is a small, free and friendly editor which aims to replace Pico, the default editor included in the non-free Pine package. On top of copying
  Pico's look and feel, nano also implements some missing (or disabled by default) features in Pico, such as "search and replace" and "go to line and
  column number".

Command: vi

vi(1p)
  This utility shall be provided on systems that both support the User Portability Utilities option and define the POSIX2_CHAR_TERM symbol. On other
  systems it is optional. The vi (visual) utility is a screen-oriented text editor. Only the open and visual modes of the editor are described in
  POSIX.1‐2008; see the line editor ex for additional editing capabilities used in vi. The user can switch back and forth between vi and ex and
  execute ex commands from within vi. This reference page uses the term edit buffer to describe the current working text. No specific implementation
  is implied by this term. All editing changes are performed on the edit buffer, and no changes to it shall affect any file until an editor command
  writes the file. When using vi, the terminal screen acts as a window into the editing buffer. Changes made to the editing buffer shall be reflected
  in the screen display; the position of the cursor on the screen shall indicate the position within the editing buffer. Certain terminals do not
  have all the capabilities necessary to support the complete vi definition. When these commands cannot be supported on such terminals, this
  condition shall not produce an error message such as “not an editor command” or report a syntax error. The implementation may either accept the
  commands and produce results on the screen that are the result of an unsuccessful attempt to meet the requirements of this volume of POSIX.1‐2008
  or report an error describing the terminal-related deficiency.

Command: rm

rm(1)
  rm removes each specified file. By default, it does not remove directories. If the -I or --interactive=once option is given, and there are more
  than three files or the -r, -R, or --recursive are given, then rm prompts the user for whether to proceed with the entire operation. If the
  response is not affirmative, the entire command is aborted. Otherwise, if a file is unwritable, standard input is a terminal, and the -f or --force
  option is not given, or the -i or --interactive=always option is given, rm prompts the user for whether to remove the file. If the response is not
  affirmative, the file is skipped.

Command:
 

منبع



برچسب ها : , , , , , , , ,