touchआदेश का प्राथमिक उद्देश्य फ़ाइलों के निर्माण के लिए फ़ाइलों के timestamps जोड़ तोड़ रहा है, और।
उदाहरण
1. फाइलें बनाना
$ ls -l
total 0
$ touch file{1..3}
$ ls -l
total 0
-rw-rw-r--. 1 saml saml 0 Jan 12 13:33 file1
-rw-rw-r--. 1 saml saml 0 Jan 12 13:33 file2
-rw-rw-r--. 1 saml saml 0 Jan 12 13:33 file3
नोट:total 0 से उत्पादन ls -lसही है। यह क्रियान्वयन lsफाइलों द्वारा सूचीबद्ध किए जाने वाले ब्लॉक की संख्या को दर्शाता है जब वे सूचीबद्ध होते हैं। आप -sस्विच में जोड़कर खुद को इस तथ्य के बारे में आश्वस्त कर सकते हैं ls। यह प्रत्येक फ़ाइल के उपयोग के ब्लॉक को सूचीबद्ध करेगा। यहाँ मैंने file1 और file2 में 2 अक्षर जोड़े हैं।
उदाहरण
$ ls -ls
total 8
4 -rw-rw-r--. 1 saml saml 3 Jan 13 12:07 file1
4 -rw-rw-r--. 1 saml saml 3 Jan 13 12:09 file2
0 -rw-rw-r--. 1 saml saml 0 Jan 13 12:05 file3
2. फाइल का समय / तारीख की जानकारी - स्टेटमेंट
$ stat file1
File: ‘file1’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 11403667 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-01-12 13:33:38.279456149 -0500
Modify: 2014-01-12 13:33:38.279456149 -0500
Change: 2014-01-12 13:33:38.279456149 -0500
Birth: -
हम touchकिसी दिए गए फ़ाइल पर विभिन्न टाइमस्टैम्प में हेरफेर करने के लिए उपयोग कर सकते हैं ।
3. टच मैन पेज से अंश
-a change only the access time
-m change only the modification time
-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time
4. पहुंच समय में हेरफेर
$ touch -a -t200001010000 file1
$ stat file1
File: ‘file1’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 11403667 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2000-01-01 00:00:00.000000000 -0500
Modify: 2014-01-12 13:33:38.279456149 -0500
Change: 2014-01-12 13:38:52.023434696 -0500
Birth: -
5. संशोधित समय में हेरफेर
$ touch -m -t200001010000 file1
$ stat file1
File: ‘file1’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 11403667 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ saml) Gid: ( 1000/ saml)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2000-01-01 00:00:00.000000000 -0500
Modify: 2000-01-01 00:00:00.000000000 -0500
Change: 2014-01-12 13:39:31.060432026 -0500
Birth: -
आप बदलाव के समय (समय) के बारे में सोच रहे होंगे। इसका उपयोग करके हेरफेर नहीं किया जा सकता है touch। उस समय को ट्रैक करता है, जब फ़ाइल पर किसी भी मेटा डेटा को छुआ गया था। अधिक विवरण के लिए इस U & L Q & A को देखें, जिसका शीर्षक है: "चेंज" टाइमपास को ट्रिगर किए बिना आप किसी फ़ाइल का क्या कर सकते हैं? ।
echo -n > filename, आप निम्न चला सकते हैं:>filename