Sponsored Content
Full Discussion: "_" in variable names
Top Forums UNIX for Dummies Questions & Answers "_" in variable names Post 302338704 by hkansal on Tuesday 28th of July 2009 04:46:35 PM
Old 07-28-2009
"_" in variable names

Hello Experts,

I have written a UNIX shell which spans about 400 lines. I have tried to manage the flow as far as possible using functions. In the main shell flow, there are certain variables, not many really - around 10. These variables would obviously act as globals.
Here I need some advice - would it be a good thing to prefix these variables with an underscore "_" to have better readability? or am I just thinking of something unnecessary?

Regards,
HKansal
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing a list of dynamic names to a "PS" command in shell script?

Hi, I am new to shell script. This is my first post .I have written a small script which returns list of names starts with "ram" in /etc/passwd .Here is that:- #!/bin/ksh NAME_LIST="name_list.txt" cat /dev/null > $NAME_LIST evalcmd="cat /etc/passwd | grep "^ram?*" | cut -d: -f1" eval... (3 Replies)
Discussion started by: sachin.tendulka
3 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

if [ "variable" = "numerical-range" ]; then

been a while so i'm a bit rusty and need a little help. writing a script that needs to compare $EXECHOST(a number) against a numerical range and then set a value. below isn't working but should give you folks an idea of my goal: if ; then echo "This is a 32B machine, exiting..." if ;... (4 Replies)
Discussion started by: crimso
4 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

The "read" command misinterprets file names containing spaces

The "read" command, which is built into bash, takes words from the standard input. However, "read" is not good at taking file names if the file names contain spaces. I would like my bash script to ask the user to enter file names, which may contain spaces. Can you think about any technique for... (14 Replies)
Discussion started by: LessNux
14 Replies

6. UNIX for Dummies Questions & Answers

Appending "_" (underscores) to variable names

Hello, I have a file, inputs.list that contain prefixes to files that are inputs for a program inputs.list A B C D E ... My files are of the format A_1, A_2, B_1, B_2 and so on. I am planning to run a shell script that takes each line from the above file and feed it to the runProg.sh... (3 Replies)
Discussion started by: Gussifinknottle
3 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
CONFGET(1)						    BSD General Commands Manual 						CONFGET(1)

NAME
confget -- read a variable from a configuration file SYNOPSIS
confget [-cSx] [-N | -n] [-f filename] [-m pattern] [-P postfix] [-p prefix] [-s section] [-t type] varname... confget [-] [-N | -n] [-f filename] [-m pattern] [-P postfix] [-p prefix] [-s section] [-t type] -L pattern... confget [-] [-N | -n] [-f filename] [-m pattern] [-P postfix] [-p prefix] [-s section] [-t type] -l confget [-hTV] DESCRIPTION
The confget utility examines a INI-style configuration file and retrieves the value of the specified variables from the specified section. Its intended use is to let shell scripts use the same INI-style configuration files as other programs, to avoid duplication of data. The confget utility may retrieve the values of one or more variables, list all the variables in a specified section, list only those whose names or values match a specified pattern (shell glob or regular expression), or check if a variable is present in the file at all. It has a ``shell-quoting'' output mode that quotes the variable values in a way suitable for passing them directly to a Bourne-style shell. Options: -c Check-only mode; exit with a code of 0 if any of the variables are present in the configuration file, and 1 if there are none. -f filename Specify the configuration file to read from, or ``-'' (a single dash) for standard input. -h Display program usage information and exit. -L Variable list mode; display the names and values of all variables in the specified section with names matching one or more specified patterns. -l List mode; display the names and values of all variables in the specified section. -m pattern Only display variables with if their values match the specified pattern. -N Always display the variable name along with the value. -n Never display the variable name, only the value. -P postfix Display this string after the variable name as a postfix. -p prefix Display this string before the variable name as a prefix. -S Quote the variable values so that the ``var=value'' lines may be passed directly to the Bourne shell. -s section Specify the configuration section to read. If this option is not specified, confget will use the first section found in the configuration file. However, if the configuration file contains variable definitions before a section header, confget will only examine them instead. -T List the available configuration file types that may be selected by the -t option. -t type Specify the configuration file type. -V Display program version information and exit. -x Treat the patterns as regular expressions instead of shell glob patterns. ENVIRONMENT
Not taken into consideration. EXIT STATUS
If the -c option is specified, the confget utility will exit with a status of 0 if any of the specified variables exist in the config file and 1 if none of them are present. In normal operation, no matter whether any variables were found in the configuration file or not, the confget utility exits with a status of 0 upon normal completion. If any errors should occur while accessing or parsing the configuration file, the confget utility will display a diagnostic message on the standard error stream and exit with a status of 1. EXAMPLES
Retrieve the variable machine_id from the system section of a configuration file: confget -f h.conf -s system machine_id Retrieve the page_id variable from an HTTP GET request, but only if it is a valid number: confget -f- -t http_get -x -m '^+$' page_id Retrieve the variable hostname from the db section, but only if it ends in ``.ringlet.net'': confget -f h.conf -s db -m '*.ringlet.net' hostname Display the names and values of all variables in the system section with names beginning with ``mach'' or ending in ``name'', appending a ``cfg_'' at the start of each variable name: confget -f h.conf -s system -p 'cfg_' -L 'mach*' '*name' Display the names and values of all variables in the system section: confget -f h.conf -s system -l Safely read the contents of the db section: eval `confget -f h.conf -s db -p db_ -S -l` SEE ALSO
For another way to parse INI files, see the Config::IniFiles(3) Perl module. STANDARDS
No standards documentation was harmed in the process of creating confget. BUGS
Please report any bugs in confget to the author. AUTHOR
The confget utility was conceived and written by Peter Pentchev <roam@ringlet.net> in 2008. BSD
October 25, 2008 BSD
All times are GMT -4. The time now is 02:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy