Skip to main content
Tweeted twitter.com/StackUnix/status/1180226226000220161
Rollback to Revision 3
Source Link
cas
  • 84k
  • 8
  • 136
  • 205

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: a shortany sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, usually in one-lineawk, perl, and/or tools like grep or cut or sort.

It may involve other languages such as sed, awk,is the direct execution on the command-line that is the defining characteristic perl,- the length and/or tools like grep or cut or sort formatting is irrelevant.

In rare cases, a A "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I would likehave my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: a short sequence of commands, usually in one-line.

It may involve other languages such as sed, awk, perl, and/or tools like grep or cut or sort.

In rare cases, a "one-liner" may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I would like this to become a canonical Q&A on the subject.

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: any sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, awk, perl, and/or tools like grep or cut or sort.

It is the direct execution on the command-line that is the defining characteristic - the length and formatting is irrelevant. A "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I have my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

Post Reopened by Wildcard, CommunityBot, GAD3R, Christopher, cas
An attempt to simplify.
Source Link
user232326
user232326

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: anya short sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, awk, perl, and/or tools like grep or cut or sortusually in one-line.

It is the direct execution on the command-line that is the defining characteristicmay involve other languages such as - the lengthsed, awk, perl, and formatting is irrelevant/or tools like grep or cut or sort. A

In rare cases, a "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I have my own answer (which I'll post later), but I wantwould like this to become a canonical Q&A on the subject, not just my personal opinion.

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: any sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, awk, perl, and/or tools like grep or cut or sort.

It is the direct execution on the command-line that is the defining characteristic - the length and formatting is irrelevant. A "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I have my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: a short sequence of commands, usually in one-line.

It may involve other languages such as sed, awk, perl, and/or tools like grep or cut or sort.

In rare cases, a "one-liner" may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I would like this to become a canonical Q&A on the subject.

Post Closed as "Opinion-based" by muru, CommunityBot, Thomas Dickey, αғsнιη, glenn jackman
Question Protected by GAD3R
added definitions
Source Link
cas
  • 84k
  • 8
  • 136
  • 205

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear) of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: any sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, awk, perl, and/or tools like grep or cut or sort.

It is the direct execution on the command-line that is the defining characteristic - the length and formatting is irrelevant. A "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I have my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

I've noticed a lot of questions and answers and comments expressing disdain (and sometimes even fear) of writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?


I have my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

I've noticed a lot of questions and answers and comments expressing disdain for (and sometimes even fear of) writing scripts instead of one-liners. So, I'd like to know:

  • When and why should I write a stand-alone script rather than a "one-liner"? Or vice-versa?

  • What are the use-cases and pros & cons of both?

  • Are some languages (e.g. awk or perl) better suited to one-liners than others (e.g. python)? If so, why?

  • Is it just a matter of personal preference or are there good (i.e. objective) reasons to write one or the other in particular circumstances? What are those reasons?

Definitions

  • one-liner: any sequence of commands typed or pasted directly into a shell command-line. Often involving pipelines and/or use of languages such as sed, awk, perl, and/or tools like grep or cut or sort.

It is the direct execution on the command-line that is the defining characteristic - the length and formatting is irrelevant. A "one-liner" may be all on one line, or it may have multiple lines (e.g. sh for loop, or embedded awk or sed code, with line-feeds and indentation to improve readability).

  • script: any sequence of commands in any interpreted language(s) which are saved into a file, and then executed. A script may be written entirely in one language, or it may be a shell-script wrapper around multiple "one-liners" using other languages.

I have my own answer (which I'll post later), but I want this to become a canonical Q&A on the subject, not just my personal opinion.

Became Hot Network Question
added 54 characters in body
Source Link
cas
  • 84k
  • 8
  • 136
  • 205
Loading
Source Link
cas
  • 84k
  • 8
  • 136
  • 205
Loading