Sponsored Content
Full Discussion: loop question
Top Forums Shell Programming and Scripting loop question Post 302260782 by Ikon on Friday 21st of November 2008 03:38:48 PM
Old 11-21-2008
$$ = The PID number of the process executing the shell.

use
Code:
dt=`date '+%Y%m%d'`

You was using:
%Y = Year
%M = Minutes (00-59)
%D = Date in %m/%d/%y format


Code:
%a Abbreviated weekday.
%b Abbreviated month name.
%c Country-specific date and time format.
%d Day of month (01-31).
%h Same as %b.
%j Julian day of year (001-366).
%k Hour in 24-hour format, without leading zeros (0-23).
%l Hour in 12-hour format, without leading zeros (1-12).
%m Month of year (01-12).
%n Insert a new line.
%p String to indicate a.m. or p.m.
%r Time in %I:%M:%S %p (12-hour) format.
%s Seconds since "the Epoch," which is 1970-01-01 00:00:00 UTC (a nonstandard extension).
%t Insert a tab.
%w Day of week (Sunday = 0).
%x Country-specific date format based on locale.
%y Last two digits of year (00-99).
%z RFC 822-style numeric time zone.
%A Full weekday.
%B Full month name.
%D Date in %m/%d/%y format.
%H Hour in 24-hour format (00-23).
%I Hour in 12-hour format (01-12).
%M Minutes (00-59).
%S Seconds (00-59).
%T Time in %H:%M:%S format.
%U Week number in year (00-53); start week on Sunday.
%V Week number in year (01-52); start week on Monday.
%W Week number in year (00-53); start week on Monday.
%X Country-specific time format based on locale.
%Y Four-digit year (e.g., 2006).
%Z Time-zone name.

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop question

hi, how would i go about making a loop which gets each line from a single text file, set it to a variable and then print it to screen? thanks eg: #!/bin/sh FILE="somefile.txt" text_line="" what kind of loop would use here? (18 Replies)
Discussion started by: strike
18 Replies

2. Shell Programming and Scripting

BASH loop inside a loop question

Hi all Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Discussion started by: rethink
4 Replies

3. Shell Programming and Scripting

For Loop Question

I'm improving the way an existing script handles arrays, but the results aren't what I had in mind: e="Too many consecutive errors... System is probably unstable!" e="Cancelable Timer Wait Failed!" for errcd in ${e} do echo ${errcd} done The for loop interprets the spaces... (2 Replies)
Discussion started by: ironhalo
2 Replies

4. Shell Programming and Scripting

loop question

hey guys what im trying to do is do a simple script that will ask for a password and on the 5th time it says access denied if the right password is still not entered this is what i have so far can anyone help me im not good with scripting thanks in advance #!/bin/bash secretname=secret... (2 Replies)
Discussion started by: randallrivy11
2 Replies

5. Shell Programming and Scripting

For Loop Question

I am struggling with the for loop. I have a file name heros.txt and I would like to go through a list in file where.txt and see if I can find the name from where inside heros. One of the problems that I am having is I dont understand how to setup the for loop to find the list to search.:wall: ... (6 Replies)
Discussion started by: captaindoogles
6 Replies

6. Shell Programming and Scripting

For loop question

Hi, I'm trying to put together a small script that will read a txt file that contains a list of two columns. Each column is the name of a folder.. e.g. AIX Server1 AIX Server2 AIX Server3 $ for i in `cat /opt/apacheprod/scripts/input/copy_list.txt` do PLATFORMVAR=`awk ' { print $1 } '... (7 Replies)
Discussion started by: Jazmania
7 Replies

7. Shell Programming and Scripting

For loop question

I have two files. In file one, there are many columns, but only two of interest to me. Column 1 contains a list of individuals, defined by an ID number. Column 10 contains the diagnosis that each individual has (I am a physician). All together, there are 3000 lines in this file, one line per... (2 Replies)
Discussion started by: awc228
2 Replies

8. Shell Programming and Scripting

While loop Question

Hi, I have a requirement where I have to check for 10 files in Unix location. If all of the files present in that directory then i have execute another process. can you help me resolving this issue. sample location /home/usr abc.txt cde.txt aaaa.txt lll.txt ooo.txt if all the... (3 Replies)
Discussion started by: manasvi24
3 Replies

9. UNIX for Dummies Questions & Answers

Loop question

Hi, I would really appreciate some help with manipulating a file. Here is my input file: SNP_1 : 1 SNP_11 : 1 SNP_2 -0.12 1 SNP_12 -0.3472 1 SNP_3 -0.708 1 SNP_13 0.5037 1 SNP_4 1.492 0.5 SNP_14 -0.0685 1 SNP_5 1.27 0.5 SNP_15 0.547 ... (3 Replies)
Discussion started by: zajtat
3 Replies

10. UNIX for Dummies Questions & Answers

Question about for loop

Hi, I have code like below disk_list=$(ls /root/file1) for disk in $disk_list do pvcreate $i done I know what pvcreate command does, but I do not understand what this $i do here. can someone please explain. (2 Replies)
Discussion started by: stew
2 Replies
clock(1T)						       Tcl Built-In Commands							 clock(1T)

__________________________________________________________________________________________________________________________________________________

NAME
clock - Obtain and manipulate time SYNOPSIS
clock option ?arg arg ...? _________________________________________________________________ DESCRIPTION
This command performs one of several operations that may obtain or manipulate strings or values that represent some notion of time. The option argument determines what action is carried out by the command. The legal options (which may be abbreviated) are: | clock clicks ?-milliseconds? | Return a high-resolution time value as a system-dependent integer value. The unit of the value is system-dependent but should be | the highest resolution clock available on the system such as a CPU cycle counter. If -milliseconds is specified, then the value is | guaranteed to be of millisecond granularity. This value should only be used for the relative measurement of elapsed time. clock format clockValue ?-format string? ?-gmt boolean? Converts an integer time value, typically returned by clock seconds, clock scan, or the atime or mtime options of the file command, to human-readable form. If the -format argument is present the next argument is a string that describes how the date and time are to be formatted. Field descriptors consist of a % followed by a field descriptor character. All other characters are copied into the result. Valid field descriptors are: %% Insert a %. %a Abbreviated weekday name (Mon, Tue, etc.). %A Full weekday name (Monday, Tuesday, etc.). %b Abbreviated month name (Jan, Feb, etc.). %B Full month name. | %c | Locale specific date and time. The format for date and time in the default "C" locale on Unix/Mac is "%a %b %d %H:%M:%S %Y". | On Windows, this value is the locale specific long date and time, as specified in the Regional Options control panel set- | tings. | %C | First two digits of the four-digit year (19 or 20). %d Day of month (01 - 31). | %D | Date as %m/%d/%y. | %e | Day of month (1 - 31), no leading zeros. | %g | The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a two-digit year-of-the-century, with leading | zero if necessary. | %G | The ISO8601 year number corresponding to the ISO8601 week (%V), expressed as a four-digit number. | %h | Abbreviated month name. %H Hour in 24-hour format (00 - 23). | %I | Hour in 12-hour format (01 - 12). %j Day of year (001 - 366). | %k | Hour in 24-hour format, without leading zeros (0 - 23). | %l | Hour in 12-hour format, without leading zeros (1 - 12). %m Month number (01 - 12). %M Minute (00 - 59). | %n | Insert a newline. %p AM/PM indicator. | %r | Time in a locale-specific "meridian" format. The "meridian" format in the default "C" locale is "%I:%M:%S %p". | %R | Time as %H:%M. | %s | Count of seconds since the epoch, expressed as a decimal integer. %S Seconds (00 - 59). | %t | Insert a tab. | %T | Time as %H:%M:%S. | %u | Weekday number (Monday = 1, Sunday = 7). %U Week of year (00 - 52), Sunday is the first day of the week. | %V | Week of year according to ISO-8601 rules. Week 1 of a given year is the week containing 4 January. | %w | Weekday number (Sunday = 0, Saturday = 6). %W Week of year (00 - 52), Monday is the first day of the week. | %x | Locale specific date format. The format for a date in the default "C" locale for Unix/Mac is "%m/%d/%y". On Windows, this | value is the locale specific short date format, as specified in the Regional Options control panel settings. | %X | Locale specific 24-hour time format. The format for a 24-hour time in the default "C" locale for Unix/Mac is "%H:%M:%S". On | Windows, this value is the locale specific time format, as specified in the Regional Options control panel settings. %y Year without century (00 - 99). %Y Year with century (e.g. 1990) %Z Time zone name. If the -format argument is not specified, the format string "%a %b %d %H:%M:%S %Z %Y" is used. If the -gmt argument is present the | next argument must be a boolean which if true specifies that the time will be formatted as Greenwich Mean Time. If false then the local timezone will be used as defined by the operating environment. clock scan dateString ?-base clockVal? ?-gmt boolean? Convert dateString to an integer clock value (see clock seconds). This command can parse and convert virtually any standard date and/or time string, which can include standard time zone mnemonics. If only a time is specified, the current date is assumed. If the string does not contain a time zone mnemonic, the local time zone is assumed, unless the -gmt argument is true, in which case the clock value is calculated assuming that the specified time is relative to Greenwich Mean Time. -gmt, if specified, affects only the computed time value; it does not impact the interpretation of -base. If the -base flag is specified, the next argument should contain an integer clock value. Only the date in this value is used, not the time. This is useful for determining the time on a specific day or doing other date-relative conversions. The dateString consists of zero or more specifications of the following form: time A time of day, which is of the form: hh?:mm?:ss?? ?meridian? ?zone? or hhmm ?meridian? ?zone?. If no meridian is specified, hh is interpreted on a 24-hour clock. date A specific month and day with optional year. The acceptable formats are mm/dd?/yy?, monthname dd ?, yy?, dd monthname ?yy?, day, dd monthname yy, ?CC?yymmdd, ?CC?yy-mm-dd, dd-monthname-?CC?yy. The default year is the current year. If the year is less than 100, we treat the years 00-68 as 2000-2068 and the years 69-99 as 1969-1999. Not all platforms can represent the | years 38-70, so an error may result if these years are used. ISO 8601 point-in-time An ISO 8601 point-in-time specification, such as CCyymmddThhmmss, where T is the literal T, CCyymmdd hhmmss, or CCyymmd- dThh:mm:ss. Note that only these three formats are accepted. The command does not accept the full range of point-in-time specifications specified in ISO8601. Other formats can be recognized by using commands such as regexp to extract their fields and reorganize them into a form accepted by the clock scan command. relative time A specification relative to the current time. The format is number unit acceptable units are year, fortnight, month, week, day, hour, minute (or min), and second (or sec). The unit can be specified as a singular or plural, as in 3 weeks. These modifiers may also be specified: tomorrow, yesterday, today, now, last, this, next, ago. The actual date is calculated according to the following steps. First, any absolute date and/or time is processed and converted. Using that time as the base, day-of-week specifications are added. Next, relative specifications are used. If a date or day is specified, and no absolute or relative time is given, midnight is used. Finally, a correction is applied so that the correct hour of the day is produced after allowing for daylight savings time differences and the correct date is given when going from the end of a long month to a short month. Daylight savings time correction is applied only when the relative time is specified in units of days or more, ie, days, weeks, fortnights, months or years. This means that when crossing the daylight savings time boundary, different results will be given for clock scan "1 day" and clock scan "24 hours": % clock scan "1 day" -base [clock scan 1999-10-31] 941443200 % clock scan "24 hours" -base [clock scan 1999-10-31] 941439600 clock seconds Return the current date and time as a system-dependent integer value. The unit of the value is seconds, allowing it to be used for relative time calculations. The value is usually defined as total elapsed time from an ``epoch''. You shouldn't assume the value of the epoch. SEE ALSO
date(1), time(1T) KEYWORDS
clock, date, time ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl 8.4 clock(1T)
All times are GMT -4. The time now is 10:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy