Sponsored Content
Full Discussion: Numbering
Top Forums Shell Programming and Scripting Numbering Post 22379 by merlin on Monday 3rd of June 2002 01:34:07 AM
Old 06-03-2002
Question Numbering

I'm trying to do a script that will look for a log file if it is already there change the name to another name.

I.E

if log.0 is there
rename to log.1
rename log.1 to log.2
rename log.2 to log.3 and so on.

Only thing is I got no idea where or what is the best command to use for this? I'm was thinking maybe mixing in sed and awk some how and doing it that way. As I said though I got no idea.

Perfect example the log files on /var/adm/log you got log.0 log.1 log.2 and so on these files have records and everytime a new log is needed the old log.X number moves up to the next number. Either it be 1 thru to 400.


If anyone can shed some light on this for me thanks a heap.

Smilie
merlin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

numbering of process

:confused: How does UNIX handle the numbering of processes? (2 Replies)
Discussion started by: tweety111
2 Replies

2. UNIX for Dummies Questions & Answers

Numbering!

Just a shot question... how to make 1,2,3,...999 into the form of 001,002,003....999 (3 digits) Thanks.... (9 Replies)
Discussion started by: biglemon
9 Replies

3. UNIX for Advanced & Expert Users

numbering blanks

hello i'm trying to figure out how to number a blank line. For instance this : sed '/./=' file | sed '/./N; s/\n/ /' gives me 1 aaaa 2 bbbbbb 4 cccccc 5 ffkkkfff 6 ffsdfdfs I would like something like this: 1 aaaaa 2 3 bbbbbb 4 5 cccccc And so... (6 Replies)
Discussion started by: wisher115
6 Replies

4. Shell Programming and Scripting

Numbering Lines

Hello everyone, I want get numbered lines from a file. and i can do it with: sed = file.txt | sed "/./N; s/\n/ /" | sed -n "5,7p" but the output that i get is something similar to: 5 line5 6 line6 7 line7 and i want something like this (with 2points after the number): 5:... (6 Replies)
Discussion started by: vibra
6 Replies

5. Shell Programming and Scripting

Numbering duplicates

Hi, I have this large file and sometimes there are duplicates and I want to basically find them and figure how many there are. So I have a file with multiple columns and the last column (9) has the duplicates. eg. yan tar tar man ban tan tub tub tub Basically what I want to... (6 Replies)
Discussion started by: kylle345
6 Replies

6. UNIX for Dummies Questions & Answers

Numbering the rows

If I a list of components, is there anyway to number (like automatically have: 1,2,3,...) the rows of my data? (1 Reply)
Discussion started by: cosmologist
1 Replies

7. Shell Programming and Scripting

help with numbering a file

Hi, All I need to do is number a file. The file looks like this > JJJJJJJJJJJJJJJJJJJJJ > JKJKJKKKKKKJJJ > MMMMYKKKJKKK what I want to do is number it so that theres a numerical value beside the >. >1 JJJJJJJJJJJJJJJJJJJJJ >2 JKJKJKKKKKKJJJ (2 Replies)
Discussion started by: kylle345
2 Replies

8. Shell Programming and Scripting

Incremental numbering?

Would it be possible for a script to duplicate a file and incrementally number it? File in: XXX_007_0580_xxxx_v0016.aep File out: XXX_007_0580_xxxx_v0017.aep If someone knows of a way I'd love to see it. Thanks! (7 Replies)
Discussion started by: scribling
7 Replies

9. Shell Programming and Scripting

Sequential numbering from 1 to ten

Hi I am in a bind, I need create a script that will rename files as they come into a folder with sequential numbering at the begining starting at 1 and proceeding to ten then starting at 1 again. Such as 1_filename.pdf, 2_filename.pdf, 3_filename.pdf, 4_filename.pdf, 5_filename.pdf, 6_filename.pdf,... (6 Replies)
Discussion started by: Paul Walker
6 Replies

10. Shell Programming and Scripting

Numbering by field

I'm not really sure how to explain this but I will try. In the attached file if $4=$4 and $5="-" then the last record is 1 and the one above that is 2, etc... However, $4=$4 and $5="-" then the first record is 1 and the one below that is 2, etc... "-" example: chr10 90694830 90695123... (7 Replies)
Discussion started by: cmccabe
7 Replies
AC(8)							    BSD System Manager's Manual 						     AC(8)

NAME
ac -- connect time accounting SYNOPSIS
ac [-dp] [-t tty] [-w wtmp] [users ...] DESCRIPTION
If the file /var/log/utx.log exists, a record of individual login and logout times are written to it by login(1) and init(8), respectively. The ac utility examines these records and writes the accumulated connect time (in hours) for all logins to the standard output. The options are as follows: -d Display the connect times in 24 hour chunks. -p Print individual users' totals. -t tty Only do accounting logins on certain ttys. The tty specification can start with '!' to indicate not this tty and end with '*' to indicate all similarly named ttys. Multiple -t flags may be specified. -w wtmp Read connect time data from wtmp instead of the default file, /var/log/utx.log. users ... Display totals for the given individuals only. If no arguments are given, ac displays the total connect time for all accounts with login sessions recorded in utx.log. The default utx.log file will increase without bound unless it is truncated. It is normally truncated by the daily scripts run by cron(8), which rename and rotate the utx.log files, keeping a week's worth of data on hand. No login or connect time accounting is performed if /var/log/utx.log does not exist. FILES
/var/log/utx.log connect time accounting file EXIT STATUS
The ac utility exits 0 on success, and >0 if an error occurs. EXAMPLES
Allow times recorded in modems to be charged out at a different rate than other: ac -p -t "ttyd*" > modems ac -p -t "!ttyd*" > other SEE ALSO
login(1), getutxent(3), init(8), sa(8) BSD
January 21, 2010 BSD
All times are GMT -4. The time now is 10:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy