Script to reinitialize the files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to reinitialize the files
# 1  
Old 09-10-2012
Script to reinitialize the files

Hi,

My requirement is :

In our AIX system we have log files like :

Code:
SH1012.LGO
sh123.txt
sh453.txt
sh267.txt
SH1015.LGO
SH1014.LGO

So i just want to reinitialize all files to zero every morning around 1 AM (which are non business hours ...I mean CST timings)

Daily I'm reinitializing them manually as >SH1012.LGO , which is a painful job.

I would like to write cronjob and excute the script to reinitialize all files during 1 AM.

So any idea how to achieve this. ( I know cronjob setting, need script now).


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 09-10-2012 at 08:14 AM.. Reason: code tags
# 2  
Old 09-10-2012
A script is about the same you do on the command line. The commands have just to be written to a file with an editor like vi for example. You then make the script exceutable and assign a cronjob for it. Try it out.
# 3  
Old 09-10-2012
Hi zaxxon,

My point here is , the files will be around 100 and which start with SH10234, I want to clear all files with one command.

I tried with:
Code:
> SH*
 ksh[2]: SH*: 0403-005 Cannot create the specified file.( this getting error while trying to execute the command)

my question is how to reinitialize all files at one go. Hope I'm clear


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 09-10-2012 at 08:32 AM.. Reason: code tags
# 4  
Old 09-10-2012
Use code tags next time for your code and data, thanks!

Code:
for a in SH*; do > $a; done

# 5  
Old 09-10-2012
Great it works.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for field wise record count for different Files .csv files

Hi, Very good wishes to all! Please help to provide the shell script for generating the record counts in filed wise from the .csv file My question: Source file: Field1 Field2 Field3 abc 12f sLm 1234 hjd 12d Hyd 34 Chn My target file should generate the .csv file with the... (14 Replies)
Discussion started by: Kirands
14 Replies

2. Shell Programming and Scripting

Renaming multiple files in sftp server in a get files script

Hi, In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this? I am using #!/bin/ksh For eg: sftp user@host <<EOF cd /path get *.txt rename *.txt *.txt.done ... (7 Replies)
Discussion started by: jhilmil
7 Replies

3. Shell Programming and Scripting

How to create or convert to pdf files from csv files using shell script?

Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks (2 Replies)
Discussion started by: ssk250
2 Replies

4. Shell Programming and Scripting

Bash script deleting my files, and editing files in subdirectories question

#!/bin/bash # name=$1 type=$2 number=1 for file in ./** do if then filenumber=00$number elif then filenumber=0$number fi tempname="$name""$filenumber"."$type" if (4 Replies)
Discussion started by: TheGreatGizmo
4 Replies

5. Shell Programming and Scripting

Read files in shell script code and run a C program on those files

HI, I am trying to implement a simple shell script program that does not make use of ls or find commands as they are quite expensive on very large sets of files. So, I am trying to generate the file list myself. What I am trying to do is this: 1. Generate a file name using shell script, for... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

6. Shell Programming and Scripting

need a shell script to extract the files from source file and check whether those files existonserve

Hi, I am new to shell scripting.Please help me on this.I am using solaris 10 OS and shell i am using is # echo $0 -sh My requirement is i have source file say makefile.I need to extract files with extensions (.c |.cxx |.h |.hxx |.sc) from the makefile.after doing so i need to check whether... (13 Replies)
Discussion started by: muraliinfy04
13 Replies

7. Shell Programming and Scripting

Need help creating a script to FTP files to a server and then delete the files that were transfered.

I am trying to FTP files to a Windows server through my Linux machine. I have setup the file transfer with no problems but am having problem deleting those files from the Linux box. My current non-working solution is below. Any ideas, anyone?? :wall: Please be gentle, I'm fairly new to this... (4 Replies)
Discussion started by: jmalfhs
4 Replies

8. Shell Programming and Scripting

Help - Bug: A script to compile two types of data files into two temporary files

Dear other forum members, I'm writing a script for my homework, but I'm scratching all over my head and still can't figure out what I did wrong. Please help me. I just started to learn about bash scripting, and I appreciate if anyone of you can point out my errors. I thank you in advance. ... (3 Replies)
Discussion started by: ilove2smoke
3 Replies

9. Shell Programming and Scripting

How to retrieve all the linked script files/ctl files/sql files?

Hi I am going to migrate our datawarehouse system from HP Tru 64 Unix to the Red Hat Linux. Inside the box, it is running around 40 cron jobs; inside each cron job, it is calling other shell script files, and the shell script files may again call other shell script files or ctl files(for... (1 Reply)
Discussion started by: franksubramania
1 Replies

10. Shell Programming and Scripting

I need a script to find socials in files and output a list of those files

I am trying to find socail security numbers in files in (and under) a specific directory and output a list of the files where they are found... the format would be with no dashes just 9 numeric characters in a row. I have tried this: find /DirToLookIn -exec grep '\{9\}' /dev/null {} \; >>... (1 Reply)
Discussion started by: NewSolarisAdmin
1 Replies
Login or Register to Ask a Question