![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Korn shell awk use for updating two files | alrinno | UNIX for Dummies Questions & Answers | 4 | 07-08-2008 03:07 PM |
| Lookup between 2 files ( korn shell ) | pavan_test | UNIX for Dummies Questions & Answers | 17 | 01-31-2006 01:07 PM |
| korn shell + sftp + list files | alienET | Shell Programming and Scripting | 1 | 03-24-2005 08:12 AM |
| how to delete empty files in a shell script | rpnuge | UNIX for Advanced & Expert Users | 1 | 07-11-2002 01:56 PM |
| Re-initializing startup files without rebooting | DrScar | UNIX for Dummies Questions & Answers | 3 | 08-20-2001 07:14 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Initializing files to empty in korn shell
hello,
i want to know how to initialize a file to an empty one in korn shell scripting? i'm using a file name and building it during a while loop using >>. The problem occurs when the file is not empty before reaching the while loop. therefore, i want to initialize it before the loop to get rid of any prior data.. how can i do that with korn shell scripting? thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
This will overwrite OR create the file
Code:
echo "" > /path/to/filename |
|
#3
|
|||
|
|||
|
thanks Ikon, but this creates an empty line at the beginning of the file. how can i achieve the same result withouth the beginning empty line?
|
|
#4
|
||||
|
||||
|
Code:
cat /dev/null > /path/to/filename |
|
#5
|
|||
|
|||
|
thank you soooo much!
|
|
#6
|
||||
|
||||
|
or a more "elegant" way
if [ -e /path/to/file ] rm /path/to/file fi altho that is an uncesesary if, you can simple try to rm it and disble output rm /path/to/file > /dev/null 2>&1 |
|
#7
|
||||
|
||||
|
Adding more shell commands matters while running shell script as it invoke subshell.
IMO echoing is good option. as echo is a builtin command. - nilesh |
||||
| Google The UNIX and Linux Forums |