awk to retrieve the first field report from atq

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am learning awk to advance my skills and tried



$ atq | awk "print $1" 
28 Wed Oct 31 10:23:00 2018
27 Tue Oct 30 21:20:00 2018
25 Tue Oct 30 21:19:00 2018
29 Wed Oct 31 10:42:00 2018
26 Tue Oct 30 21:20:00 2018
20 Tue Oct 30 18:25:00 2018
30 Wed Oct 31 10:59:00 2018
32 Wed Oct 31 21:03:00 2018
23 Tue Oct 30 18:28:00 2018
31 Wed Oct 31 13:58:00 2018
19 Tue Oct 30 15:43:00 2018
21 Tue Oct 30 18:27:00 2018


It did not work as I expected, but it's relatively easy to work small programs together



$ atq | cut -f 1
28
27
25
29
26
20
30
32
23
31
19
21


How could I retrieve the first field using awk?










share|improve this question







New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    You need single quotes around the awk commands.
    – ewatt
    40 mins ago














up vote
1
down vote

favorite












I am learning awk to advance my skills and tried



$ atq | awk "print $1" 
28 Wed Oct 31 10:23:00 2018
27 Tue Oct 30 21:20:00 2018
25 Tue Oct 30 21:19:00 2018
29 Wed Oct 31 10:42:00 2018
26 Tue Oct 30 21:20:00 2018
20 Tue Oct 30 18:25:00 2018
30 Wed Oct 31 10:59:00 2018
32 Wed Oct 31 21:03:00 2018
23 Tue Oct 30 18:28:00 2018
31 Wed Oct 31 13:58:00 2018
19 Tue Oct 30 15:43:00 2018
21 Tue Oct 30 18:27:00 2018


It did not work as I expected, but it's relatively easy to work small programs together



$ atq | cut -f 1
28
27
25
29
26
20
30
32
23
31
19
21


How could I retrieve the first field using awk?










share|improve this question







New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    You need single quotes around the awk commands.
    – ewatt
    40 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am learning awk to advance my skills and tried



$ atq | awk "print $1" 
28 Wed Oct 31 10:23:00 2018
27 Tue Oct 30 21:20:00 2018
25 Tue Oct 30 21:19:00 2018
29 Wed Oct 31 10:42:00 2018
26 Tue Oct 30 21:20:00 2018
20 Tue Oct 30 18:25:00 2018
30 Wed Oct 31 10:59:00 2018
32 Wed Oct 31 21:03:00 2018
23 Tue Oct 30 18:28:00 2018
31 Wed Oct 31 13:58:00 2018
19 Tue Oct 30 15:43:00 2018
21 Tue Oct 30 18:27:00 2018


It did not work as I expected, but it's relatively easy to work small programs together



$ atq | cut -f 1
28
27
25
29
26
20
30
32
23
31
19
21


How could I retrieve the first field using awk?










share|improve this question







New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I am learning awk to advance my skills and tried



$ atq | awk "print $1" 
28 Wed Oct 31 10:23:00 2018
27 Tue Oct 30 21:20:00 2018
25 Tue Oct 30 21:19:00 2018
29 Wed Oct 31 10:42:00 2018
26 Tue Oct 30 21:20:00 2018
20 Tue Oct 30 18:25:00 2018
30 Wed Oct 31 10:59:00 2018
32 Wed Oct 31 21:03:00 2018
23 Tue Oct 30 18:28:00 2018
31 Wed Oct 31 13:58:00 2018
19 Tue Oct 30 15:43:00 2018
21 Tue Oct 30 18:27:00 2018


It did not work as I expected, but it's relatively easy to work small programs together



$ atq | cut -f 1
28
27
25
29
26
20
30
32
23
31
19
21


How could I retrieve the first field using awk?







bash awk






share|improve this question







New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 47 mins ago









Sawajiri

1586




1586




New contributor




Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Sawajiri is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    You need single quotes around the awk commands.
    – ewatt
    40 mins ago












  • 1




    You need single quotes around the awk commands.
    – ewatt
    40 mins ago







1




1




You need single quotes around the awk commands.
– ewatt
40 mins ago




You need single quotes around the awk commands.
– ewatt
40 mins ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote













Try the below,



atq | awk 'print $1'


The single quotes stops the shell from expanding $1 to the shell's first positional parameter.






share|improve this answer






















  • great, could you please elaborate the reasons.
    – Sawajiri
    41 mins ago










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "",
contentPolicyHtml: "",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);






Sawajiri is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478890%2fawk-to-retrieve-the-first-field-report-from-atq%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote













Try the below,



atq | awk 'print $1'


The single quotes stops the shell from expanding $1 to the shell's first positional parameter.






share|improve this answer






















  • great, could you please elaborate the reasons.
    – Sawajiri
    41 mins ago














up vote
5
down vote













Try the below,



atq | awk 'print $1'


The single quotes stops the shell from expanding $1 to the shell's first positional parameter.






share|improve this answer






















  • great, could you please elaborate the reasons.
    – Sawajiri
    41 mins ago












up vote
5
down vote










up vote
5
down vote









Try the below,



atq | awk 'print $1'


The single quotes stops the shell from expanding $1 to the shell's first positional parameter.






share|improve this answer














Try the below,



atq | awk 'print $1'


The single quotes stops the shell from expanding $1 to the shell's first positional parameter.







share|improve this answer














share|improve this answer



share|improve this answer








edited 41 mins ago









Kusalananda

112k15216344




112k15216344










answered 43 mins ago









EBIN GLADSON

3816




3816











  • great, could you please elaborate the reasons.
    – Sawajiri
    41 mins ago
















  • great, could you please elaborate the reasons.
    – Sawajiri
    41 mins ago















great, could you please elaborate the reasons.
– Sawajiri
41 mins ago




great, could you please elaborate the reasons.
– Sawajiri
41 mins ago










Sawajiri is a new contributor. Be nice, and check out our Code of Conduct.









 

draft saved


draft discarded


















Sawajiri is a new contributor. Be nice, and check out our Code of Conduct.












Sawajiri is a new contributor. Be nice, and check out our Code of Conduct.











Sawajiri is a new contributor. Be nice, and check out our Code of Conduct.













 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478890%2fawk-to-retrieve-the-first-field-report-from-atq%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery