Sponsored Content
Top Forums Shell Programming and Scripting Howto shorten script in a busybox environment by using for loops? Post 302399060 by ni_hao on Friday 26th of February 2010 06:44:27 AM
Old 02-26-2010
Thanks, looks much much better. However, some commands are not recognized at the busybox I use. I tried your source code and it gave errors:

This is not recognized:

Code:
  day$j=$[$day$i+1]                # day1 = day of today + 1 so tomorrows date

and returns with

Code:
day1=201002261: command not found

So it did not add 1 day to today but put the 1 behind the date of today.
With other words: it should give 27 but it gave: 201002261

In that construction $day$i is seen as two variables: $day and $i that is why the result is: 20100226 and 1; combined to 201002261

Last edited by ni_hao; 02-26-2010 at 07:54 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Howto read data into a shell script

Hi all, I'm anew shell user, and want to now how to do that? i have a files that have inside few raws of names of directories, i want to read only the lins that are a dir name how to do so. the file looks like that #################################### # This is the list of dirs files ... (4 Replies)
Discussion started by: banjo
4 Replies

2. Shell Programming and Scripting

howto run remotely call function from within script

Hi I have the following script : #!/bin/ksh #################### Function macAddressFinder ######################## macAddressFinder() { `ifconfig -a > ipInterfaces` `cat ipInterfaces` } ####################################################################### # # print... (2 Replies)
Discussion started by: presul
2 Replies

3. Shell Programming and Scripting

script to shorten usernames and output to file

Hopefully someone here can point me in the correct direction. I'm working on a username migration and am trying to map my users ols usernames to the new ones. Right now every user has a username of firstname.lastname i.e. john.doe I'm trying to create a bash or python script that will take... (3 Replies)
Discussion started by: binary-ninja
3 Replies

4. Shell Programming and Scripting

Need help optimizing this piece of code (Shell script Busybox)

I am looking for suggestions on how I could possibly optimized that piece of code where most of the time is spend on this script. In a nutshell this is a script that creates an xml file(s) based on certain criteria that will be used by a movie jukebox. Example of data: $SORTEDTMP= it is a... (16 Replies)
Discussion started by: snappy46
16 Replies

5. Shell Programming and Scripting

Script loops again and again and again and ...

Hi, Linux newbie here with what I'm guessing is silly questions. My script below is working in that it correctly copies files from the backup IP (10.0.91.1) back down to the Linux server but trouble is it loops continuously. It correctly downloads 100 files from the the IP 10.0.91.1... (1 Reply)
Discussion started by: MOWS
1 Replies

6. Shell Programming and Scripting

Bash Script to Ash (busybox) - Beginner

Hi All, I have a script that I wrote on a bash shell, I use it to sort files from a directory into various other directories. I have an variable set, which is an array of strings, I then check each file against the array and if it is in there the script sorts it into the correct folder. But... (5 Replies)
Discussion started by: sgtbobie
5 Replies

7. UNIX for Dummies Questions & Answers

How to shorten my code?

salary_range_report() { echo -e ${underline}$redYellow"\nSalary Range Report\n" tput sgr0 count_0_to_999=0 count_1000_to_2999=0 count_2000_to_5999=0 count_6000_to_9999=0 count_10000_above=0 for i in `cut -d "," -f4 $PAYROLL` #Loop Salary do if && then let... (4 Replies)
Discussion started by: eggisbad
4 Replies

8. UNIX for Dummies Questions & Answers

How can i use function for the below script to shorten it?

Hi All, i worte a shell script which will zcat the .gz file and write it in to a tmp file and then again cat the file and convert it to Dos mode. Next step is i am greping the file to search for the particular string on the 1st line and if the string does not exits it will insert the 1st line... (1 Reply)
Discussion started by: vikatakavi
1 Replies

9. Shell Programming and Scripting

Ps command and awk - shorten characters

ps -e -o pcpu -o pid -o user -o args | sort -k 1 | tail -6r %CPU PID USER COMMAND 0.3 223220 root /usr/tivoli/tsm/client/ba/bin/dsmc sched 0.2 411332 root /usr/sbin/syslogd 0.1 90962 root /usr/sbin/syncd 60 0.0 10572 root -ksh 0.0 94270 root -ksh ... (4 Replies)
Discussion started by: SkySmart
4 Replies

10. UNIX for Advanced & Expert Users

Howto stop loops in CentOS

Good morning, At the client location os is CentOS. In all the terminals i.e F1, F2, F3....F10 PING command is continuously running. I tried to terminate it using CTRL C or quit but unable to stop that command in all the terminals. How to stop that? Howto find batch files which are being... (3 Replies)
Discussion started by: sureshbabu.anis
3 Replies
Time::ParseDate(3pm)					User Contributed Perl Documentation				      Time::ParseDate(3pm)

NAME
Time::ParseDate -- date parsing both relative and absolute SYNOPSIS
use Time::ParseDate; $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1) $seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options) OPTIONS
Date parsing can also use options. The options are as follows: FUZZY -> it's okay not to parse the entire date string NOW -> the "current" time for relative times (defaults to time()) ZONE -> local timezone (defaults to $ENV{TZ}) WHOLE -> the whole input string must be parsed GMT -> input time is assumed to be GMT, not localtime UK -> prefer UK style dates (dd/mm over mm/dd) DATE_REQUIRED -> do not default the date TIME_REQUIRED -> do not default the time NO_RELATIVE -> input time is not relative to NOW TIMEFIRST -> try parsing time before date [not default] PREFER_PAST -> when year or day of week is ambiguous, assume past PREFER_FUTURE -> when year or day of week is ambiguous, assume future SUBSECOND -> parse fraction seconds VALIDATE -> only accept normal values for HHMMSS, YYMMDD. Otherwise days like -1 might give the last day of the previous month. DATE FORMATS RECOGNIZED
Absolute date formats Dow, dd Mon yy Dow, dd Mon yyyy Dow, dd Mon dd Mon yy dd Mon yyyy Month day{st,nd,rd,th}, year Month day{st,nd,rd,th} Mon dd yyyy yyyy/mm/dd yyyy-mm-dd (usually the best date specification syntax) yyyy/mm mm/dd/yy mm/dd/yyyy mm/yy yy/mm (only if year > 12, or > 31 if UK) yy/mm/dd (only if year > 12 and day < 32, or year > 31 if UK) dd/mm/yy (only if UK, or an invalid mm/dd/yy or yy/mm/dd) dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy) dd/mm (only if UK, or an invalid mm/dd) Relative date formats: count "days" count "weeks" count "months" count "years" Dow "after next" Dow "before last" Dow (requires PREFER_PAST or PREFER_FUTURE) "next" Dow "tomorrow" "today" "yesterday" "last" dow "last week" "now" "now" "+" count units "now" "-" count units "+" count units "-" count units count units "ago" Absolute time formats: hh:mm:ss[.ddd] hh:mm hh:mm[AP]M hh[AP]M hhmmss[[AP]M] "noon" "midnight" Relative time formats: count "minutes" (count can be franctional "1.5" or "1 1/2") count "seconds" count "hours" "+" count units "+" count "-" count units "-" count count units "ago" Timezone formats: [+-]dddd GMT[+-]d+ [+-]dddd (TZN) TZN Special formats: [ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd] yy/mm/dd.hh:mm DESCRIPTION
This module recognizes the above date/time formats. Usually a date and a time are specified. There are numerous options for controlling what is recognized and what is not. The return code is always the time in seconds since January 1st, 1970 or undef if it was unable to parse the time. If a timezone is specified it must be after the time. Year specifications can be tacked onto the end of absolute times. If "parsedate()" is called from array context, then it will return two elements. On sucessful parses, it will return the seconds and what remains of its input string. On unsucessful parses, it will return "undef" and an error string. EXAMPLES
$seconds = parsedate("Mon Jan 2 04:24:27 1995"); $seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995"); $seconds = parsedate("04.04.95 00:22", ZONE => PDT); $seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1); $seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1); $seconds = parsedate("+3 secs", NOW => 796978800); $seconds = parsedate("2 months", NOW => 796720932); $seconds = parsedate("last Tuesday"); $seconds = parsedate("Sunday before last"); ($seconds, $remaining) = parsedate("today is the day"); ($seconds, $error) = parsedate("today is", WHOLE=>1); LICENSE
Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. License hereby granted for anyone to use, modify or redistribute this module at their own risk. Please feed useful changes back to cpan@dave.sharnoff.org. perl v5.12.3 2011-05-20 Time::ParseDate(3pm)
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy