I would like to extract only /home/user01\ruuidd:x:108:114::/run/uuuidd:/usr/sbin/nologin
from the code string below. What should I do?
#include <stdio.h>#include <stdlib.h>#include <string.h> int main(){ char str[1024]="\r\n\033[?2004l\r/home/user01\ruuidd:x:108:114::/run/uuidd:/usr/sbin/nologin\r\n\033[?2004h\033]0;user01@audit: ~\auser01@audit:~$ "; char *ptr = strtok(str + 1, "\r"); strcpy(str, ptr + 1); ptr = strtok(str, "\r\n\033"); printf("%s\n",ptr); return 0; }
The execution result of the code I made is as follows.
root@audit:~# ./test
output : [?2004l