December 21st, 2012, 10:01 AM
Question: writing to a file
I had a quick question. Is there a differnce between
echo $$ >somefile.txt
echo $$ >> somefile.txt
December 21st, 2012, 10:47 AM
The first syntax (with 1 >) will destroy any existing file having that name before writing to it. The second one (with >>) will append whatever you write to the existing content of the file.
December 21st, 2012, 10:48 AM
According to your posting history, all of your questions have been related to shell scripting, not Perl. Shell script questions are best asked in the Linux or UNIX topic areas.
The focus of your question here is not language specific, so it's not much of a faux pas.
The > redirection operator will send the output to somefile.txt overwriting the file if it already existed, or creating it if it didn't exist.
The >> operator will append the output to the end somefile.txt, creating the file if it didn't already exist.