On the Usefulness of AWK in a Job Setting [closed] - bash

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have been learning AWK in my UNIX class, which has been really fun; but I have been wondering how useful my AWK skills will be in a future job environment. It seems that text formatting is something that does not generally need to be handled on the command line in the way something like a shell script task necessarily would. Also, are potential employers going to care whether something esoteric like AWK is on my resume?

I have been learning AWK in my UNIX class, which has been really fun;
but I have been wondering how useful my AWK skills will be in a future
job environment.
If you are expecting to work in a field related to systems administration or even software development on Unix-like platforms, knowing AWK can be incredibly useful. It is a standard tool in many shell scripts.
It seems that text formatting is something that does not generally need to be handled on the command line...
Well, AWK isn't really about text formatting. It's about extracting data from text streams.
Also, are potential employers going to care whether something esoteric like AWK is on my resume?
Not at all. They may care that you are able to competently write shell scripts, but it's not something that will be called out explicitly. It's such a basic skill that listing it on your resumé would look like padding.

Related

Recommended convention / coding style [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I am in a process of refactoring some unix shell scripts
and find many inconsistencies and different styles in our code
For example:
somevar="${item1},${item2}"
somevar=${item1}","${item2}
somevar="$item1,$item2"
Is there a coding style guide for unix shell scripts? or a formatter like clang-format for C++
[Edit] Please note I am not asking for personal style preferences or personal opinion! I am looking for an industry standard document, a widely used style guide or a popular tool.
I've worked in a few companies that have their own style guides but most now use Google's style guide. If you don't have a home grown style guide then Google's is good and is published here: https://google.github.io/styleguide/shell.xml
I personally check my shell scripts with the shellcheck plugin for vim but it's available on the web and for other editors. You can use it and get the downloads here: https://www.shellcheck.net/
Since word splitting won't happen in the context of a variable assignment you could just use:
somevar=${item1},${item2}
I personally prefer to use
somevar="${item1},${item2}"
The quotes doesn't hurt and - imo - increase readability.
About ${var} vs. $var. That matters when the variable name may contain an underscore, like "$foo_bar". What does it mean? The variable $foo plus the literal string _bar? Or the expansion of the variable $foo_bar? I would consequently use ${var} to avoid such situations.

Why is bash's print statement `echo` instead of `print`? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
"Print" seems to have good representation across a lot of programming languages, even in older stuff like Fortran (1957). Why is it that bash (1989) uses echo rather than print for the function that prints to the screen?
Is there some fascinating history of computing story, or something mundane? Is the design decision related to the fact that $ man print gives me information about whatever MAILCAP is?
Little more research, echo appears to have been introduced (as a built-in function) in the original Bourne shell after 1984: https://en.wikipedia.org/wiki/Bourne_shell Apparently, it existed non-built-in before that.
Update from comments (via Wumpus Q. Wumbley): earliest echo reference this thread has found so far is V3 (1972)
Semantically, echo is not the same as what a print statement can be in a programming language. echo is a simple program that outputs the same input it gets, which within bash scripts is very useful for print stuff, but it's not its purpose.
print in most program languages are a shortcut to write to stdout. That happens to print to a console but can also print to a file or to a printer. IMHO, they are conceptually different and can't be comparable.

How to validate a raw Zebra Programming Language (ZPL) file with a regular expression? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
When receiving ZPL raw labels (text files) from a third party, I would like to run a regular expression on them to validate them.
Rather than a 100% strict validation, I am mostly looking to avoid sending to the printer obviously wrong files, such as completely unrelated text files, or binary files.
I am not familiar enough with ZPL/ZPL-II and I would prefer to use an existing resource for that. Would you know if one exists?
I've never heard of one. But it wouldn't be too hard to validate. ZPL is pretty straightforward, especially if there's a very defined set that you send to your printer...
The ZPL command characters are ~ for immediate commands an ^ for formatting commands.
Label formats must begin with a ^XA and end with a ^XZ.
Download commands typically begin with a ~D<something>, like ~DY, ~DG, ~DT, ~DC etc.
There are a couple status commands like ~HI and ~HS
There may be a couple other edge cases, but these are the most common commands.

Writing a code beautifier [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'd like to write a code beautifier and i thought of using Ruby to do it. Could someone show me a place to get started? I've seen a lot of code beautifiers online but I've never come across any tutorials on how to write one. Is this a very challenging task for someone who's never undertaken any projects such as writing a compiler, parser, etc. before?
(Is there another langauge which would be more well suited for this kind of task, excluding C/C++?)
Python has an interesting feature - it exposes its own parser to scripts. There are examples that use the AST - abstract syntax tree - and do the pretty printing.
I'm not aware that Ruby exposes its own parser to its scripts in such a way, but there are parsers for Ruby written in Ruby here.
Well... I think the initial steps are what you'd do for any project.
Write a list of requirements.
Describe a user interface to your program, that you like and won't prevent you meeting those requirements.
Now you can write down more of a "code" design, and pick the language that would be easiest for you to meet that design.
Here's some requirements off the top of my head:
Supports code beautifying of these languages: Ruby, Python, Perl
Output code behaves identically to input
Output has consistent use of tabs/spaces
Output has consistent function naming convention
Output has consistent variable naming convention
Output has matching braces and indentation
Make as many as you want, it's your program. ;p I was kidding about the Perl, but I think every language you support is going to add a more work.

Should command line options in POSIX-style operating systems be underscore style? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Should the name of command line options for a program in a POSIX-style operating system be underscore-style, like
--cure_world_hunger
or maybe some other style?
--cureworldhunger
--cure-world-hunger
--cureWorldHunger
What's most common? What's better style? What's more Bash-friendly (if such a thing exist)?
Underscore is not a good idea, sometimes it gets "eaten" by a terminal border and thus look like a space.
The easiest to read, and most standard way is to use a dash:
--cure-world-hunger
Always hyphens! Let's get a reputed reference: the Gnu style guide:
GNU adds long options to these conventions. Long options consist of
‘--’ followed by a name made of alphanumeric characters and dashes.
Option names are typically one to three words long, with hyphens to
separate words. Users can abbreviate the option names as long as the
abbreviations are unique.
Another problem with underscores is that if the documentation is linked in a HTML document, the link underline will hide the underscore and will confuse the user.
The double dash prefix is a GNU convention I believe. Check out getopt_long(3) man page on the GNU/Linux Operating System.

Resources