I need to periodically empty a text file without deleting it (I know how many lines it has).
I tried this:
Created a cron that executes the following script
other lines from the script here
sed '1,14d' file.txt>file.txt
If I run it from a terminal it works fine, but when I run the cron it executes the first part (the "other lines from script here" part) but it doesn't empty the file.
Note: The file has 777 permissions so I don't think it's permissions related.
sed 1,14d file > file
works: the shell will see the redirection and truncate the file before executing the sed command.