In my case cut doesn't work. I m searching for a particular user from a
password.
$ grep anil /etc/passwd


Best Regards
Jenisha T
Whatsapp: +91 07598087866





On Mon, 6 Jul 2020 at 19:50, Stefan Hornburg (Racke) <[email protected]>
wrote:

> On 7/6/20 3:32 PM, Srinivas Naram wrote:
> > Hello Jenisha,
> >
> > Assuming that you are getting this value from /etc/passwd., try to
> change you command
> >
> >  tail -1 /etc/passwd | awk '{split($0,a,":"); print a[1]}'
> >
>
> cut -d : -f 1 is more concise and readable than your awk command.
>
> Otherwise I would really like to know why Jenisha resorts to reading the
> password file.
>
> Regards
>          racke
>
>
> > On Mon, Jul 6, 2020 at 6:35 PM Dick Visser <[email protected]
> <mailto:[email protected]>> wrote:
> >
> >     you should either use set_fact, or register. Both doesn't make sense.
> >
> >     On Mon, 6 Jul 2020 at 13:44, Jenisha T <[email protected] <mailto:
> [email protected]>> wrote:
> >     >
> >     > Hi
> >     > Could you pls help me with the splitting value from the list. I
> need to extract first value anil before ('':')
> >     >
> >     >  grep_atm.stdout_lines output below
> >     >
> >     > ok: [localhost] => {
> >     >     "msg": "anil:x:500:500:Anil:/home/anil:/bin/bash
> >     > "
> >     > }
> >     >
> >     > I tried,
> >     > - set_fact:
> >     >        user_name: "{{ grep_atm.stdout_lines }}"
> >     >         register: user_name.split(':')[0]
> >     >  - debug:
> >     >         var: user_name.split(':')[0]
> >     >
> >     > --
> >     > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> >     > To unsubscribe from this group and stop receiving emails from it,
> send an email to
> >     [email protected] <mailto:
> ansible-project%[email protected]>.
> >     > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/42fb2917-8336-42a2-979a-44573e91fd77n%40googlegroups.com
> .
> >
> >
> >
> >     --
> >     Dick Visser
> >     Trust & Identity Service Operations Manager
> >     GÉANT
> >
> >     --
> >     You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> >     To unsubscribe from this group and stop receiving emails from it,
> send an email to
> >     [email protected] <mailto:
> ansible-project%[email protected]>.
> >     To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMo1%3D9XhddQY_BDaREzKLRGS_xDvZbtu1o5UCj0R1h%3Duw%40mail.gmail.com
> .
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to
> > [email protected] <mailto:
> [email protected]>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com
> > <
> https://groups.google.com/d/msgid/ansible-project/CAG-N3P7NNjnbv7fZ5Vx0vmmTTyd9KntKpY-yOm75csqJ50cBmA%40mail.gmail.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b4c85876-5359-f104-cd6f-03667cd7f93b%40linuxia.de
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAAGhZYjxvOgKKa1pFfh5oAp2JDzyeOmW0SE8zFM_j3vTefgaUw%40mail.gmail.com.

Reply via email to