Shell Programing with awk Tool


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Programing with awk Tool
# 1  
Old 05-12-2009
Shell Programing with awk Tool

I'm working on a program in with shell programming and it needs to be able to delete the contents of files in the Home directory on certain days of the week.(like tuesday). Can anyone help me with this?

Thanks in advance, Taffy.
# 2  
Old 05-12-2009
Can you show us the code you have so far, and tell us how it misbehaves?

Regards
# 3  
Old 05-13-2009
All that I have so far is this

#!/bin/bash
date | awk '[ if $1 =="Tue" rm -rf File ]' //I tried this but it didnt work
if [ $1="Tue" ] // When i tried this it kept jumping to wrong indicating $1 !="Tue"
then rm -rf File
else
echo "Wrong"
fi
# 4  
Old 05-14-2009
Quote:
Originally Posted by Taffy
All that I have so far is this

#!/bin/bash
date | awk '[ if $1 =="Tue" rm -rf File ]' //I tried this but it didnt work
if [ $1="Tue" ] // When i tried this it kept jumping to wrong indicating $1 !="Tue"
then rm -rf File
else
echo "Wrong"
fi
Should be something like:

Code:
dat=$(date "+%a")

if [ "$dat" = "Tue" ]; then
  # your actions
fi

# 5  
Old 05-14-2009
Thank you that worked but how would i be able to determine the three oldest files?(these would be the ones i would delete)
what function would i use to count and display the files in the home directory?
Sorry i know this is asking a lot but I could realy use the help, my exams dont leave me with alot of time.
thanks in advance.
# 6  
Old 05-15-2009
Check the manpages of ls and tail.
# 7  
Old 05-18-2009
how would you archive a file using tar with and give it a differnt name?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Doubt in awk programing

i wrote an awk progarm to calculate throughput from a ns2 trace file. i want this program to act on multiple trace files and it should display each output in a single output file can anyone please clear my doubt i tried with awk -f awkscript inputfile1... (7 Replies)
Discussion started by: sarathyy
7 Replies

2. Homework & Coursework Questions

need help with shell programing script

1. The problem statement, all variables and given/known data: Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the frequency in seconds at... (5 Replies)
Discussion started by: operator
5 Replies

3. Programming

Shell programing to implement SQL package

hi all, i have a table with employee details like his name,addr,DOB etc. i need a shell program which takes one date as input from user and print the employees whose DOB is less than that date. in sql package the select query is written (2 Replies)
Discussion started by: vidyaj
2 Replies

4. Shell Programming and Scripting

New tool for shell scripting

Hi All, It's quite long time....m comming to my favourite forum.. Can anyone suggest me good tool like eclipse for Java....do we have anything for Shell scripting..where n i can atlease prepare script...rather than typing all mistakes in Linux box :) Thanks Sha (1 Reply)
Discussion started by: Shahul
1 Replies

5. Shell Programming and Scripting

shell programing...

Hi... i need to write a shell script wich shows the full name and station of every logged user in the system. pls help! (1 Reply)
Discussion started by: relu89
1 Replies

6. Programming

A C++ programing Shell on Win

Hello I need to translade the power of unix command shell (grep, sed, awk, wc, etc..) to windows. In my work every day I administrate 15 unix server ans 18 windows server, and I have the problem the absolutly limitation of windows shell. I´m a system administrator but I know programming. I... (2 Replies)
Discussion started by: dalmus
2 Replies

7. Shell Programming and Scripting

Awk Programing (need help)

plx help to solve these problems?? 1. Create a HERE document which will edit multiple files in the same directory, using the ed editor. I give you 3 original files: file1.c , file2.c , file3.c, download them and change each string "stdio.h" to "STDIO.H" in these files. Note: when execute the... (1 Reply)
Discussion started by: SoCalledEngr
1 Replies

8. Linux

Linux game programing or just shell scripting

Well Acording to my job... Anyhelp plz. I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies

9. Shell Programming and Scripting

Editing files in shell programing

Hi folks, In our product installation program we edit xml files by deleting lines and appending new lines instead of them. For example: update_Log4plsql_xml() { machineName=`uname -n` hostIP=`cat /etc/hosts | grep ${machineName} | cut -f1` trap 'clean_up | tee -a $installLog ; exit' 1 2... (0 Replies)
Discussion started by: nir_s
0 Replies

10. Shell Programming and Scripting

mutex in shell programing

A shell in crontab per 5 min write a file B shell in crontab per 6 min read a file how to lock the share file a ;avioid confilict in write and read? Thx : -) (1 Reply)
Discussion started by: zz_xm
1 Replies
Login or Register to Ask a Question