Skip to main content

All Questions

0 votes
1 answer
207 views

Instruct shell script to do a task if the output of a program contains a specific word

I need to create a program in Bash that launches a command, check if the result contain a word, and do something if it does. Example: I need to check if a printer is online with lpstat -p [printer ...
Othin's user avatar
  • 1
-1 votes
1 answer
137 views

Custom data formatting and pattern matching

I am trying to format custom data using pattern match. I am not getting expected format. Though I am not shell script savvy but I was able to build a script based on references from multiple sources ...
Steve Rick's user avatar
4 votes
1 answer
929 views

How to ensure user input consists of exactly 6 digits

I am running HP-UX 11.23 and have a bash script that reads two inputs. Both inputs need to be exactly 6 digits long. What is the best way to read the input and if its not 6 numbers ask the users to ...
Steve's user avatar
  • 41
0 votes
2 answers
490 views

Bash brace expansion with variables for pattern matching

I want to loop through all files matching a pattern of the form for file in {prefix1, prefix2, ...}*{postfix1, postfix2, ...}; do How can I programmatically replace {prefix1, prefix2, ...} with a ...
Hyperplane's user avatar
0 votes
1 answer
580 views

Vim search and replace positional arguments

I am trying to replace positional arguments with variables in my bash script using Vim's substitute :scommand. Example: I would like to replace the following text in a bash script: python3 mymodule....
ccrowley's user avatar