"Delete file"의 두 판 사이의 차이

6번째 줄: 6번째 줄:
[[category: Bash]]
[[category: Bash]]
<source lang='Bash'>
<source lang='Bash'>
echo hello > /tmp/a.txt
echo 'John Smith' > /tmp/a.txt
if [ ! -f /tmp/a.txt ]; then echo 'File not found'; fi
if [ ! -f /tmp/a.txt ]; then echo 'File not found #1'; fi


rm -f /tmp/a.txt
rm -f /tmp/a.txt
if [ ! -f /tmp/a.txt ]; then echo 'File not found'; fi
if [ ! -f /tmp/a.txt ]; then echo 'File not found #2'; fi
# File not found
# File not found
</source>
==PHP==
[[category: PHP]]
<source lang='PHP'>
file_put_contents('/tmp/a.txt', 'John Smith');
if( !file_exists('/tmp/a.txt') ) echo 'File not found #1'.PHP_EOL;
unlink('/tmp/a.txt');
if( !file_exists('/tmp/a.txt') ) echo 'File not found #2'.PHP_EOL;
// File not found #2
</source>
</source>


==같이 보기==
==같이 보기==
*[[file_exists]]
*[[file_exists]]

2014년 8월 31일 (일) 16:01 판

unlink
rm

1 Bash

echo 'John Smith' > /tmp/a.txt
if [ ! -f /tmp/a.txt ]; then echo 'File not found #1'; fi

rm -f /tmp/a.txt
if [ ! -f /tmp/a.txt ]; then echo 'File not found #2'; fi
# File not found

2 PHP

file_put_contents('/tmp/a.txt', 'John Smith');
if( !file_exists('/tmp/a.txt') ) echo 'File not found #1'.PHP_EOL;

unlink('/tmp/a.txt');
if( !file_exists('/tmp/a.txt') ) echo 'File not found #2'.PHP_EOL;
// File not found #2

3 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}