Sponsored Content
Top Forums Shell Programming and Scripting awk help : if then else not working! Post 302797997 by Corona688 on Tuesday 23rd of April 2013 03:02:40 PM
Old 04-23-2013
The code your error shows and the code you show is not the same, which is right?

I don't think you need the ; before the else.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk not working for me.

Hi All, I have a server.xml file which looks something like. <Connector port="8443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100"... (2 Replies)
Discussion started by: nua7
2 Replies

2. Shell Programming and Scripting

awk not working in script

Hi All, i'm trying awk commnad to read only file names with the help of below command :- ls -l tmp*.txt | awk { 'print $9' } | head -1 The command is working fine :o on command line, but when i trying it in script then its not working $var1=`ls -l tmp*.txt | awk { 'print $9' } | head -1`... (3 Replies)
Discussion started by: doitnow
3 Replies

3. UNIX for Dummies Questions & Answers

Logical AND, OR not working with awk.

awk -F^ '{ if ((($1 == "M") && ($5 == "2")) || (($1 == "S") && ($5 == "7"))) print $0}' welcome > welcome1 When I run the above awk command, I could see the same content of welcome in welcome1. Later, I found that the logicals "&&", "||" used in the above command is not working. Can any... (2 Replies)
Discussion started by: karthickrn
2 Replies

4. Shell Programming and Scripting

awk command not working

Hi all, Trying to write a script that reads a file and prints everything after a certain string is found to the end of the file. Awk is giving me an error and not sure why it doesn't work: # cat test_file Mon Nov 16 2009 16:11:08 abc def Tue Nov 17 2009 16:08:06 ghi jkl Wed Nov 18... (8 Replies)
Discussion started by: jamie_collins
8 Replies

5. UNIX for Advanced & Expert Users

Awk expressions working & not working

Hi, Putting across a few awk expressions. Apart from the last, all of them are working. echo a/b/c | awk -F'/b/c$' '{print $1}' a echo a/b/c++ | awk -F'/b/c++' '{print $1}' a echo a/b/c++ | awk -F'/b/c++$' '{print $1}' a/b/c++ Request thoughts on why putting a '$' post double ++... (12 Replies)
Discussion started by: vibhor_agarwali
12 Replies

6. Shell Programming and Scripting

[awk] working with two files

Hello guys, I have little to no experience working with two files in awk and hope you can help me with a problem that may be easy for you to solve... awk -v cut1="$var1" -v cut2="$var2" '{split($0, arr1); for(i=1;i<=NF;i++) if (arr1 < cut1) print arr1, NR, i}' file1 file2 The above code is... (4 Replies)
Discussion started by: origamisven
4 Replies

7. Shell Programming and Scripting

awk isn't working

awk 'BEGIN{print '1.2449'**0.5}' awk: line 1: syntax error at or near * can someone help me troubleshoot the above command? i'm trying to do the square root of 1.2449. this command works on Red Hat, but for some reasonn isn't working on kubuntu (latest version). shell is bash. i... (3 Replies)
Discussion started by: SkySmart
3 Replies

8. Shell Programming and Scripting

awk not working correctly

Hi I am attempting to right a script which will read a table and extract specfic information. LASTFAILEDJOB=/usr/openv/netbackup/scripts/GB-LDN/Junaid/temp_files/lastfailedjob cat /usr/openv/netbackup/scripts/GB-LDN/Junaid/temp_files/lastfailedjob 237308646 If i run the following... (5 Replies)
Discussion started by: Junes
5 Replies

9. Shell Programming and Scripting

awk - why this is not working? trying next word!

Hi Experts, Can you please advise , why I am not able to make it work, or why this is not working: I spent quite a lot of time on this figuring out , but not working, file : This is a test file thanks for your reply This is another file again Have a nice day this is a small file... (3 Replies)
Discussion started by: rveri
3 Replies

10. Shell Programming and Scripting

Awk: System command not working in awk

Hi, I have around 10 files in a folder in which I want to change the file format from tab(\t) to pipe(|) with some changes in the fields as well. Below is the code, while tmp file is getting generated but move command is not working, please help Following is the code awk -F"\t" '{print... (2 Replies)
Discussion started by: siramitsharma
2 Replies
GIT-SHOW-REF(1) 						    Git Manual							   GIT-SHOW-REF(1)

NAME
       git-show-ref - List references in a local repository

SYNOPSIS
       git show-ref [-q|--quiet] [--verify] [--head] [-d|--dereference]
		    [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
		    [--heads] [--] [<pattern>...]
       git show-ref --exclude-existing[=<pattern>]

DESCRIPTION
       Displays references available in a local repository along with the associated commit IDs. Results can be filtered using a pattern and tags
       can be dereferenced into object IDs. Additionally, it can be used to test whether a particular ref exists.

       By default, shows the tags, heads, and remote refs.

       The --exclude-existing form is a filter that does the inverse. It reads refs from stdin, one ref per line, and shows those that don't exist
       in the local repository.

       Use of this utility is encouraged in favor of directly accessing files under the .git directory.

OPTIONS
       --head
	   Show the HEAD reference, even if it would normally be filtered out.

       --tags, --heads
	   Limit to "refs/heads" and "refs/tags", respectively. These options are not mutually exclusive; when given both, references stored in
	   "refs/heads" and "refs/tags" are displayed.

       -d, --dereference
	   Dereference tags into object IDs as well. They will be shown with "^{}" appended.

       -s, --hash[=<n>]
	   Only show the SHA-1 hash, not the reference name. When combined with --dereference the dereferenced tag will still be shown after the
	   SHA-1.

       --verify
	   Enable stricter reference checking by requiring an exact ref path. Aside from returning an error code of 1, it will also print an error
	   message if --quiet was not specified.

       --abbrev[=<n>]
	   Abbreviate the object name. When using --hash, you do not have to say --hash --abbrev; --hash=n would do.

       -q, --quiet
	   Do not print any results to stdout. When combined with --verify this can be used to silently check if a reference exists.

       --exclude-existing[=<pattern>]
	   Make git show-ref act as a filter that reads refs from stdin of the form "^(?:<anything>s)?<refname>(?:^{})?$" and performs the
	   following actions on each: (1) strip "^{}" at the end of line if any; (2) ignore if pattern is provided and does not head-match
	   refname; (3) warn if refname is not a well-formed refname and skip; (4) ignore if refname is a ref that exists in the local repository;
	   (5) otherwise output the line.

       <pattern>...
	   Show references matching one or more patterns. Patterns are matched from the end of the full name, and only complete parts are matched,
	   e.g.  master matches refs/heads/master, refs/remotes/origin/master, refs/tags/jedi/master but not refs/heads/mymaster or
	   refs/remotes/master/jedi.

OUTPUT
       The output is in the format: <SHA-1 ID> <space> <reference name>.

	   $ git show-ref --head --dereference
	   832e76a9899f560a90ffd62ae2ce83bbeff58f54 HEAD
	   832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/master
	   832e76a9899f560a90ffd62ae2ce83bbeff58f54 refs/heads/origin
	   3521017556c5de4159da4615a39fa4d5d2c279b5 refs/tags/v0.99.9c
	   6ddc0964034342519a87fe013781abf31c6db6ad refs/tags/v0.99.9c^{}
	   055e4ae3ae6eb344cbabf2a5256a49ea66040131 refs/tags/v1.0rc4
	   423325a2d24638ddcc82ce47be5e40be550f4507 refs/tags/v1.0rc4^{}
	   ...

       When using --hash (and not --dereference) the output format is: <SHA-1 ID>

	   $ git show-ref --heads --hash
	   2e3ba0114a1f52b47df29743d6915d056be13278
	   185008ae97960c8d551adcd9e23565194651b5d1
	   03adf42c988195b50e1a1935ba5fcbc39b2b029b
	   ...

EXAMPLE
       To show all references called "master", whether tags or heads or anything else, and regardless of how deep in the reference naming
       hierarchy they are, use:

		   git show-ref master

       This will show "refs/heads/master" but also "refs/remote/other-repo/master", if such references exists.

       When using the --verify flag, the command requires an exact path:

		   git show-ref --verify refs/heads/master

       will only match the exact branch called "master".

       If nothing matches, git show-ref will return an error code of 1, and in the case of verification, it will show an error message.

       For scripting, you can ask it to be quiet with the "--quiet" flag, which allows you to do things like

		   git show-ref --quiet --verify -- "refs/heads/$headname" ||
			   echo "$headname is not a valid branch"

       to check whether a particular branch exists or not (notice how we don't actually want to show any results, and we want to use the full
       refname for it in order to not trigger the problem with ambiguous partial matches).

       To show only tags, or only proper branch heads, use "--tags" and/or "--heads" respectively (using both means that it shows tags and heads,
       but not other random references under the refs/ subdirectory).

       To do automatic tag object dereferencing, use the "-d" or "--dereference" flag, so you can do

		   git show-ref --tags --dereference

       to get a listing of all tags together with what they dereference.

FILES
       .git/refs/*, .git/packed-refs

SEE ALSO
       git-for-each-ref(1), git-ls-remote(1), git-update-ref(1), gitrepository-layout(5)

GIT
       Part of the git(1) suite

Git 2.17.1							    10/05/2018							   GIT-SHOW-REF(1)
All times are GMT -4. The time now is 11:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy