Sponsored Content
Full Discussion: shell variables advanced
Top Forums Shell Programming and Scripting shell variables advanced Post 302338983 by cfajohnson on Wednesday 29th of July 2009 11:33:13 AM
Old 07-29-2009
Quote:
Originally Posted by edidataguy
4. For $IFS do the same as before:
Code:
 
    set | grep "$IFS"


Why use grep? It may give a lot more than the value of IFS:

Code:
$ set | grep IFS
DIFS=$' \t\n'
IFS=$' \t\n'
oldIFS=$' \t\n'
    oldIFS=$IFS;
    IFS=" -./";
    IFS=$oldIFS;
    IFS=:;
    oldIFS=$IFS;
    IFS=":";
    IFS=$oldIFS;
            printf "%s\n" "$IFS" "$OLD_IFS" 1>&2
            oldIFS
            newIFS
    local IFS=.;
    local IFS=.;
        IFS=$NL;
    IFS=" $TAB$NL";
newIFS () 
    if [ -n "${IFS+X}" ]; then
        OLD_IFS=${OLD_IFS}SET:$IFS;
        IFS=$1;
        OLD_IFS=${OLD_IFS}UNSET;
oldIFS () 
    case $OLD_IFS in 
            unset IFS
            IFS=${OLD_IFS##*SET:};
            OLD_IFS=${OLD_IFS%SET:*}
        IFS=: eval "printf \"%s\n\" \$PATH";

All you need is:

Code:
printf 'IFS=%s\n" "$IFS"

This User Gave Thanks to cfajohnson For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using shell variables In awk

Oh its not my day for syntax... cat gzipsize.txt | awk '{print "echo",$1,$2} > master.txt I have read a lot about the awk -v but haven't been able to get it to work. I have a variable in my script and I'm looking just to push it into the awk after the $2 (or anywhere would do)!!! Every... (11 Replies)
Discussion started by: nortypig
11 Replies

2. Shell Programming and Scripting

variables in shell

hi, i'm new in shell scripting and i'm working on bash on solaris 5.9 after try many stuff with unexpected results, i wonder: it is not posible in bash, to use a variable that was created inside a loop, out of it? i mean, for instance: cat mytext | \ while read text do viko=$text... (2 Replies)
Discussion started by: viko
2 Replies

3. Post Here to Contact Site Administrators and Moderators

Where can I download the VTC - Unix Shell Scripting Advanced complete video

Where can I download the VTC - Unix Shell Scripting Advanced complete video. I don't know in which thread I should post this question.Plz help me out, or just tell me the link in the reply to this post. Thanks in advance. (0 Replies)
Discussion started by: villain41
0 Replies

4. Shell Programming and Scripting

$0 shell variables

Would appreciate if someone can explain the ${0##*/} line. What does it do? I am aware that $0 is the script name, $# is number of arguments passed in, $* is all the arguments. With the curly brackets {} added in, what's the eventual effect? Does ${0##*/} actually equals $0$#$*? (something like... (3 Replies)
Discussion started by: new2ss
3 Replies

5. Shell Programming and Scripting

Advanced error handling in shell scripts

Hi all I've got a question regarding error handling in shell scripts. My background is mainly object oriented programming languages, but for a year or so I've been doing more and more (bash) shell scripting (which I quite enjoy by the way). To handle errors in my scripts I... (3 Replies)
Discussion started by: script_man
3 Replies

6. Shell Programming and Scripting

Shell advanced syntax?

I am not an expert of shell scripting, but I can do some simple things. Now, I read a script written by others and I need some help from the experts of this forum. Please help me to understand what is going on in this cycle: if ; then ] && \ export... (25 Replies)
Discussion started by: alt
25 Replies

7. Homework & Coursework Questions

Trouble with Advanced Shell Programming

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am working on a hands on project. We are creating a script for a corporate phone list. The project I am... (2 Replies)
Discussion started by: SarahBelle7858
2 Replies

8. Shell Programming and Scripting

awk - take variables out to shell

Hi, How could we take the value of awk variables out to shell? I know the following methods 1. awk '{print $1}' < file | read a echo $a 2. a=`awk '{print $1}' < file` echo $a Please let me know if there are any other methods. Also, how do we take more than 1 variable value... (4 Replies)
Discussion started by: Thumban
4 Replies

9. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

10. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 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 09:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy