Sponsored Content
Top Forums Shell Programming and Scripting Understanding awk 'expansion' Post 302959250 by Scrutinizer on Friday 30th of October 2015 03:07:33 PM
Old 10-30-2015
Quote:
Originally Posted by cjcox
Code:
awk -v U=$(whoami) -F: '"/^" U "/" {print $6}' /etc/passwd

Hi, I do not think this will work. That evaluates to:
Code:
awk -F: '"/^username/"{print $6}' /etc/passwd

Which means if the string "/^username/" is true (i.e. non-empty) then print $6

So this always evaluates to true and it will print field 6 on every line..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Understanding Awk and Cat

Hi Guys, I was recently come across some code to hopefully learn a little bit about putting Shell commands into PHP application to run on a Linux server. However, I don't understand the command AT ALL... and was wondering if anyone can interpret it: cat userIDs.dat | awk '{s=s+1; if... (1 Reply)
Discussion started by: jordRiot
1 Replies

2. Shell Programming and Scripting

Need to print the expansion of the found string (the expansion is beween two delimiters '-' , '||'

Hi , could anyone help me out with this problem. sample.txt has this content : u001- this is used for project1 || u002- this is used for p2|| not to be printed u003- this is used for project3 || u004- this is used for p4 || u005- this is used for project5 || u006- this is used for p6... (9 Replies)
Discussion started by: Balaji PK
9 Replies

3. UNIX for Advanced & Expert Users

understanding awk in this script

i am analyzing a query written by another developer ,need to understand part of script am looking at a code ..and it converts comma files to pipe delimited and also takes away quotes from any columns, source field format: 2510,"Debbie",NewYork changes to target: 2510|Debbie|NewYork ... (1 Reply)
Discussion started by: coolrock
1 Replies

4. UNIX for Dummies Questions & Answers

Understanding / Modifying AWK command

Hey all, So I have an AWK command here awk '{if(FNR==NR) {arr++;next} if($0 in arr) { arr--; if (arr == 0) delete arr;next}{print $0 >"list2output.csv"}} END {for(i in arr){print i >"list1output.csv"}}' list1 list2 (refer to image for a more readable format) This code was submitted... (1 Reply)
Discussion started by: Aussiemick
1 Replies

5. Shell Programming and Scripting

Help in understanding awk expression

Hi, Could somebody help me in understanding the following awk expression: awk -v n="POINT" '/%/{print $0 "\n" n ;next}1' < file name Thanks, Arun (6 Replies)
Discussion started by: arun_maffy
6 Replies

6. Shell Programming and Scripting

Help in Understanding awk if ( F ) syntax -

Hi Experts, I was looking at the below link, for finding words next to it, And unable to understand this syntax: Can any one please explain , what is meaning of this code: if ( F ) s = s ? s OFS $i : $i from:... (4 Replies)
Discussion started by: rveri
4 Replies

7. UNIX for Dummies Questions & Answers

Understanding awk

I found this on an awk site and would like to know what it does: /CARS/{x="";next} {if(x)print x;x=$0} END{if(x)print x}' Does it mean if it finds the word cars it skips that line and then prints the next one? (4 Replies)
Discussion started by: newbie2010
4 Replies

8. Shell Programming and Scripting

awk : Need Help in Understanding a command

Hello I am working on a Change request and Stuck at a point. The below awk command is used in the function. float_test ( ) { echo | awk 'END { exit ( !( '"$1"')); }' } I understand that awk 'END' is used to add one line at the end and exit is used to end the script with an error... (4 Replies)
Discussion started by: rahul2662
4 Replies

9. Shell Programming and Scripting

Shell variable expansion in awk

I want to split one file input.tab into two separate ones, odd lines to input_reads1.txt, even lines to input_reads2.txt for a serial of files with similar name pattern. Also I want to "match" input/output file names to keep consistency of file name: CSEL_02.0_input.tab CSEL_03.4_input.tab... (2 Replies)
Discussion started by: yifangt
2 Replies

10. Shell Programming and Scripting

Bash variable expansion in awk script

Hello, I need to split a file into two of different locations by re-direction in awk. cat infle aaa 1 3 bbb 2 4 aaa 3 3 bbb 4 4 aaa 5 3 bbb 6 4 cat /storage/tmp/group_a.gtf aaa 1 3 aaa 3 3 aaa 5 3 cat /storage/tmp/group_b.gtf bbb 2 4 bbb ... (2 Replies)
Discussion started by: yifangt
2 Replies
cancel(1)																 cancel(1)

NAME
cancel - cancel print request SYNOPSIS
cancel [ request-ID...] [destination...] cancel -u user... [destination...] The cancel utility cancels print requests. There are two forms of the cancel command. The first form of cancel has two optional arguments: print requests (request-ID) and destinations (destination). Specifying request-ID with destination cancels request-ID on destination. Specifying only the destination cancels the current print request on destination. If desti- nation is not specified, cancel cancels the requested print request on all destinations. The second form of cancel cancels a user's print requests on specific destinations. Users can only cancel print requests associated with their username. By default, users can only cancel print requests on the host from which the print request was submitted. If a super-user has set user-equivalence=true in /etc/printers.conf on the print server, users can cancel print requests associated with their username on any host. Super-users can cancel print requests on the host from which the print request was submitted. Superusers can also cancel print requests from the print server. The print client commands locate destination information using the printers database in the name service switch. See nsswitch.conf(4), printers(4), and printers.conf(4) for details. The following options are supported: -u user The name of the user for which print requests are to be cancelled. Specify user as a username. The following operands are supported: destination The destination on which the print requests are to be canceled. destination is the name of a printer or class of printers (see lpadmin(1M)). If destination is not specified, cancel cancels the requested print request on all destinations. Specify destination using atomic or POSIX-style (server:destination), names. See for information regarding using POSIX-style des- tination names with cancel. See standards(5) for information regarding POSIX. request-ID The print request to be canceled. Specify request-ID using LP-style request IDs (destination-number). user The name of the user for which the print requests are to be cancelled. Specify user as a username. The following exit values are returned: 0 Successful completion. non-zero An error occurred. /var/spool/print/* LP print queue. $HOME/.printers User-configurable printer database. /etc/printers.conf System printer configuration database. printers.conf.byname NIS version of /etc/printers.conf. printers.org_dir NIS+ version of /etc/printers.conf. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWpcu | +-----------------------------+-----------------------------+ lp(1), lpq(1B), lpr(1B), lprm(1B), lpstat(1), lpadmin( 1M), nsswitch.conf(4), printers(4), printers.conf(4), attributes(5), standards(5) POSIX-style destination names (server:destination) are treated as print requests if destination has the same format as an LP-style request- ID. See standards(5). Some print servers send cancelation notification to job owners when their print jobs have been cancelled. This notification usually comes in the form of an email message. Cancelation notices cannot be disabled on a Solaris server. 23 Feb 2005 cancel(1)
All times are GMT -4. The time now is 04:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy