Sponsored Content
Full Discussion: bash scripting and awk help
Top Forums Shell Programming and Scripting bash scripting and awk help Post 302352209 by streetfighter2 on Thursday 10th of September 2009 05:54:04 PM
Old 09-10-2009
Quote:
Originally Posted by vgersh99
To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

---------- Post updated at 05:34 PM ---------- Previous update was at 05:31 PM ----------

cannot you simply do this:
Code:
awk -F, '{print $1, $3}' "${filename}"

I'm not quite sure what you're trying to filter out with the trailing grep......
Hi sorry for being such a n00b. I am trying to grep for a valid ip address in the trailing grep, because the $3 field in the input file has other values other than ip addresses and I am trying to filter for valid ip's. Also I haven't got a valid hostname regex working yet for the $1 field.

Which brings me back to:
Code:
awk -F, '{print $1, $3}' "${filename}"

I'm mainly stuck on finding if they both exist on the same line and if true resolve the hostname to ip.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash/awk scripting help (creating OLD new users)

I need some help making this script... I guess I'm having trouble even interpretating what to even get started on... I need to create a script that will search a given directory (typically a user's home directory, but not necessarily) as provided on the command line and any sub-directors for... (2 Replies)
Discussion started by: Jukai
2 Replies

2. Shell Programming and Scripting

bash scripting help

hi all i'm trying to get a script working upon connection with pppd According to docu this happens ina clean environment with a couple of variables set, namely $1,$2,... To be able to execute the statements i included a path statement but i think i'm running into trouble with the variables -... (6 Replies)
Discussion started by: jimjones
6 Replies

3. Shell Programming and Scripting

bash scripting help!!

Hi, can anyone help me with my scrip please. I wanted do following tasks: 1. List all the directory 2. A STDIN to ask user to enter a directory name from listed directories 3. command to check if the directory exists( or a command to validate if the user entered a valid directory name)... (3 Replies)
Discussion started by: eminjan
3 Replies

4. Shell Programming and Scripting

please help with Bash Scripting????

Hi, can anyone help me with my scrip please. I wanted do following tasks: 1. List all the directory 2. A STDIN to ask user to enter a directory name from listed directories 3. command to check if the directory exists( or a command to validate if the user entered a valid directory name) ... (2 Replies)
Discussion started by: eminjan
2 Replies

5. Shell Programming and Scripting

scripting help with bash and awk

I'm trying to reformat some tide information into a useable format and failing. Input file is.... 4452 CHENNAI (MADRAS) 13°06'N, 80°18'E India East Coast 01 June 2009 UT(GMT) Data Area 3. Indian Ocean (northern part) and Red Sea to Singapore 01/06/2009 00:00 0.7 m 00:20 0.7 m 00:40... (3 Replies)
Discussion started by: garethsays
3 Replies

6. Homework & Coursework Questions

bash,scripting

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 have to do this but i am confused, Create a file containing the bash functions which perform the... (1 Reply)
Discussion started by: CRAZYLITTLELOU
1 Replies

7. Shell Programming and Scripting

bash scripting help

have this code but when i run it i get this error ./pulse: line 2: and here is the code #!/bin/bash if ; then pulseaudio -k; fi what am i doing wrong thanks Adam (5 Replies)
Discussion started by: ab52
5 Replies

8. Shell Programming and Scripting

Bash scripting

Try to imagine a flag: nnnnx nnnxx nnxxx nxxxx now imagine how it will output: 4 times the "n"and 1 times "x" 3 times "n"and" 2 times" x " .. etc. .. rhombus is the same only instead of "n" is there gap "and " x "is a few times to form the correct shape Can you help... (3 Replies)
Discussion started by: krcek12
3 Replies

9. Shell Programming and Scripting

bash scripting help

Hi Guys i have a <script?> that spits out the location of each printer using snpget here is the code for i in `sed -n '/Start Printer/,/End Printer/p' /hosts/blah/etc/dhcp/hosts.conf | awk '!/^#/ {print $2}' | egrep -v \... (2 Replies)
Discussion started by: ab52
2 Replies

10. Shell Programming and Scripting

bash scripting

same script: 1- i am using grep to find a string called: tinker panic 0 in a file /etc/ntp.conf if the string is not there, i want to add the strings in /etc/ntp.conf file in the first line of the file. if not do nothing or exit. 2- also i want to add # in front of the following lines in... (0 Replies)
Discussion started by: lamoul
0 Replies
whereami(8)						      System Manager's Manual						       whereami(8)

NAME
whereami -- non-interatively ascertain the location of the computer and reconfigure the system appropriately. SYNOPSIS
whereami [--debug ] [--scriptdebug ] [--syslog ] [--noactions ] [--nolocking ] [--mapping ] [--basedir directory ] [--statedir directory ] [--from location_list ] [--run_from calling_program_tag ] [location_list] DESCRIPTION
`whereami' provides a configurable and extensible framework for automatic location-detection and reconfiguration of computers, typically laptops. Detection Detection is handled through the use of various network and hardware probing tools. These tools have been wrapped in small shell scripts to interface them to whereami, but the end-user with different requirements may wish to extend these in some situations. whereami processes the file /etc/whereami/detect.conf performing the tests specified in there in order to decide which location the com- puter is currently located at. For full detail on the discovery process, you should read the detect.conf (5) manpage. Configuration Configuration is handled through standard shell scripting. A variety of small utility scripts are provided and the author is always will- ing to accept more. The file /etc/whereami/whereami.conf is parsed and a script built containing the actions specified there which are associated with the locations found during the detection phase. Actions may be configured for when leaving, remaining, or arriving at a location. Once the script has been built, it is run to effect the necessary changes to the system configuration. OPTIONS
This program follows the modern command-line syntax preceding each option with a double dash (`--'). Short form options are also avail- able, but are not documented (RTFC :-) --debug Run in debugging mode. A verbose output is provided and the resulting script is output to the screen and not executed. --scriptdebug Run in script debugging mode. Each script supplied with `whereami' will `set -o xtrace' if the environment variable `DEBUGWHERE- AMI' is set to non-blank. This parameter will set that variable. The script which is built by whereami will also respond to the environment variable. --syslog Output some logging information to syslog. The 'user' facility is used for this, and it provides an insight into which locations whereami has chosen, and why. In combination with --scriptdebug above, this can be very useful for debugging your configuration. Also note that the default installation turns this on for apm and init actions. --noactions Just do the detection and print the location name. Don't build and run the script from whereami.conf. You might do this if you wanted to use whereami's detection, but use something else for configuration. Perhaps you could achieve the same end with a very simple whereami.conf, but there should always be two ways to do anything :-). --nolocking whereami won't normally let two copies of whereami run at the same time. Use this option if you can come up with a scenario where you should allow this to happen! --mapping This will persuade whereami to do only the detection stage, and output a list of the detected locations, suitable for use as a mapping script with ifupdown. --hint locations Provides some hints to the detection process. The locations set by this parameter (a comma-delimited list) may be referenced by rules in your detect.conf. --basedir directory Specifies the base directory which will contain both the detect.conf and whereami.conf. The default is `/etc/whereami' which should be right for normal use. --statedir directory Specifies the state directory in which whereami will write files indicating the current and previous locations (iam , iwas) and the script which is run for this environment (whereiam.sh). --from location_list Overrides whereami's knowledge of where you have come from. The location_list will be a comma-separated list of the locations which you are leaving. Normally `whereami' maintains a history of locations, so that it knows where you have come from (and what might consequently have to be de-configured) as well as knowing that your location has changed. --run_from calling_program_tag This provides a mechanism for calling software, such as init scripts, pcmcia startup or apm events, to pass some of that source information to whereami, where it is promptly ignored, at present. I have a possibly misguided idea that this might be useful somehow, but I can't think of any application of it at this point! location_list Overrides whereami's testing of where you are. The location_list will be a comma-separated list of the locations which you are now at. You might use this if you wished to bypass the detection phase, using some other package to handle that. SEE ALSO
detect.conf (5), whereami.conf (5) There is some further documentation in HTML available in /usr/share/doc/whereami/manual FILES
/etc/whereami/detect.conf Defines the process of detection. /etc/whereami/whereami.conf Defines the actions performed as a result of entering, leaving, or remaining within a particular location. KNOWN BUGS
This man page only documents the current perl version of whereami. For backward compatibility with people's setups, it is possible to con- figure your system to run the older shell-script, which is currently undocumented. If you wish to switch from the shell script to the new perl program you will need to create an appropriate `detect.conf' file to define your location detection parameters. Your existing whereami.conf file should be compatible with this version. Once you have created a detect.conf file in /etc/whereami you should run `dpkg-reconfigure whereami' and respond to the questions. AUTHOR
This manual page was written by Andrew McMillan <debian@mcmillan.net.nz> for the Debian GNU/Linux system (but may be used by others). Per- mission is granted to copy, distribute and/or modify this document under the terms of the GPL version 2. whereami(8)
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy