The same way of thinking differently shell script way

Source: Internet
Author: User
Tags strtok

Shell: ##################################### echo "Time is" date=$ (DATE +%y%m%d) echo $DATE echo "creat a fileder named by Time "Mkdir-p $DATEread-P" input number: "num if [$num-eq] then mv $DATE" Pass "fi
#include  <stdio.h> #include <string.h> #include  <time.h> #include  <sys/stat.h > #include <sys/types.h> #include <unistd.h>  int main (void) {     time_t now;    struct tm *tm_now;    char     dt[200];      char x=0;    time (& Now);     tm_now = localtime (&now);     strftime (dt,  200,  "%x %x %y-%m-%d",  tm_now);      printf ("Now datetime  : %s\n ", &NBSP;DT);       char *s = strtok (DT,"   ");           s = strtok (NULL, " ");           s = strtok (NULL, " ");         &nBsp;const char *str = s;          mkdir ( str,0777)       puts ("Enter  X  start Move Folder");        x=getchar ();     if (x!=0)       {      pid_t pid = fork ();      if (pid == 0)   &NBSP;&NBSP;&NBSP;{&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;EXECLP ("MV", "MV", str, "./pass", NULL);         return 0;    }      else    {        printf ("file has moved \ n");  &NBSP;&NBSP;&NBSP;}&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;//&NBSP;EXECLP ("MV", "MV", str, "./pass", NULL);    //  method 1       }    return  0;}

Bat

Set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"

MD%ymd%

Pause

Move%ymd% C:\Users\Administrator\Desktop\pass

Pause


The same way of thinking differently shell script way

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.