Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Create a file with input values required Post 302849175 by jiam912 on Saturday 31st of August 2013 06:20:19 AM
Old 08-31-2013
RudiC

Here the last,,, Thanks a lot for your helpSmilieSmilie

Code:
      printf "Please enter the swath numbers in order of recording.\n"
      printf "\n"
             read -p "Last swath for the previous shipment: " lastsw1
      printf "\n"
             read -p "Last swath for actual shipmenth : " lastsw2


fsw=2351
lsw1=$lastsw1
fsw2=`expr $lastsw1 - 1`
lsw2=$lastsw2


set $fsw $lsw1 $fsw2 $lsw2

echo "" $(($1-$2+$3-$4+2)) > swseq.tmp
printf " %s          0 \n" $(seq $1 -1 $2) >> swseq.tmp
printf " %s          1 \n" $(seq $3 -1 $4) >> swseq.tmp

unix2dos -q swseq.tmp

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create a directory structure with getting input from a file.

Hi How to create a directory structure with getting input from a file. I have file in that following lines are written. ./activemq-4.1.2/activemq-core-4.1.2.jar ./activemq-4.1.2/backport-util-concurrent-2.1.jar ./camel-1.4.0/apache-camel-1.4.0.jar ./camel-1.4.0/lib/activation-1.1.jar... (12 Replies)
Discussion started by: itsjoy2u
12 Replies

2. UNIX for Dummies Questions & Answers

create an input file

I am using a large unix server at my college. I have remote access to it on my laptop. I have installed a program on the large unix server, and want to write to the program. How do I alter parameters to read input and write output somewhere else?. I would like to read input and write output to my... (2 Replies)
Discussion started by: stonna
2 Replies

3. UNIX for Dummies Questions & Answers

Create file with column values

Hi, I have a data file looks like the following ID STARTDATE ENDDATE 101 20090520 20090521 102 20090521 20090522 103 20090522 20090523 104 20090523 20090524 105 20090524 20090525 106 20090525 20090526 107 ... (3 Replies)
Discussion started by: naveen.kuppili
3 Replies

4. Shell Programming and Scripting

Create Multiple files by reading a input file and changing the contents

Being new to this area .I have been assigned a task which i am unable to do . Can any one please help me . Hi I have requirement where i have input file XYZ_111_999_YYYYMMDD_1.TXT and with header and series of Numbers and Footer. I want to create a mutiple output files with each file having a... (2 Replies)
Discussion started by: bhargavkr
2 Replies

5. Shell Programming and Scripting

Print required values at end of the file by using AWK

I am looking help in awk, quick overview. we will get feed from external system . The input file looks like below. Detail Id Info Id Order Id STATUS Status Date FileDetail 99127942 819718 CMOG223481502 PR 04-17-2011 06:01:34PM... (7 Replies)
Discussion started by: dvrbabu
7 Replies

6. Shell Programming and Scripting

How to generate a csv files by separating the values from the input file based on position?

Hi All, I need help for doing the following. I have a input file like: aaaaaaaaaabbbbbbbbbbbbbbbbbbbb cccbbbbbaaaaaadddddaaaabbbbbbb now I am trying to generate a output csv file where i will have for e.g. 0-3 chars of each line as the first column in the csv, 4-10 chars of the line as... (3 Replies)
Discussion started by: babom
3 Replies

7. Shell Programming and Scripting

Create different files from input file.

I have file A.txt File A 1,Hi,234 2,Hello,345 1,Kal,980, 9,KJ,098 2,de,098 .. ... I have more then 600 lines... I want separate the files as per 150 line. First 150 lines ----File A1.xtx Second 150 lines ---File A2.txt Third 150 lines----File A3.txt. ... (4 Replies)
Discussion started by: asavaliya
4 Replies

8. Shell Programming and Scripting

Replace two values in a file with input from two different files

Hi, I was having the following issue cat input hello1, my name is unix.com. I am awesome. Hope you know this, hello2! cat hello1.txt Hi Friends Hi Folks Hi Well-Wishers cat hello2.txt Honey Sweety Darling Required Output (8 Replies)
Discussion started by: jacobs.smith
8 Replies

9. Shell Programming and Scripting

Bash to search file based off user input then create new file

In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file. For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Shell Programming and Scripting

Check if 2 input values exists in a file

I have a file number.txt.I need to get 2 inputs from the terminal like a=100 and b=200.If a and b are there in the file,then check if a < b,print "less".If a is not there in the file,print "a is missing" or if b is not there in the file,print "b is missing". number.txt: 100 200 300 (2 Replies)
Discussion started by: aneeta13
2 Replies
GETDATE(3)						     Linux Programmer's Manual							GETDATE(3)

NAME
getdate, getdate_r - convert a date-plus-time string to broken-down time SYNOPSIS
#include <time.h> struct tm *getdate(const char *string); extern int getdate_err; #include <time.h> int getdate_r(const char *string, struct tm *res); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): getdate(): _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED getdate_r(): _GNU_SOURCE DESCRIPTION
The function getdate() converts a string representation of a date and time, contained in the buffer pointed to by string, into a broken- down time. The broken-down time is stored in a tm structure, and a pointer to this structure is returned as the function result. This tm structure is allocated in static storage, and consequently it will be overwritten by further calls to getdate(). In contrast to strptime(3), (which has a format argument), getdate() uses the formats found in the file whose full pathname is given in the environment variable DATEMSK. The first line in the file that matches the given input string is used for the conversion. The matching is done case insensitively. Superfluous whitespace, either in the pattern or in the string to be converted, is ignored. The conversion specifications that a pattern can contain are those given for strptime(3). One more conversion specification is specified in POSIX.1-2001: %Z Timezone name. This is not implemented in glibc. When %Z is given, the structure containing the broken-down time is initialized with values corresponding to the current time in the given timezone. Otherwise, the structure is initialized to the broken-down time corresponding to the current local time (as by a call to local- time(3)). When only the weekday is given, the day is taken to be the first such day on or after today. When only the month is given (and no year), the month is taken to be the first such month equal to or after the current month. If no day is given, it is the first day of the month. When no hour, minute and second are given, the current hour, minute and second are taken. If no date is given, but we know the hour, then that hour is taken to be the first such hour equal to or after the current hour. getdate_r() is a GNU extension that provides a reentrant version of getdate(). Rather than using a global variable to report errors and a static buffer to return the broken down time, it returns errors via the function result value, and returns the resulting broken-down time in the caller-allocated buffer pointed to by the argument res. RETURN VALUE
When successful, getdate() returns a pointer to a struct tm. Otherwise, it returns NULL and sets the global variable getdate_err to one of the error numbers shown below. Changes to errno are unspecified. On success getdate_r() returns 0; on error it returns one of the error numbers shown below. ERRORS
The following errors are returned via getdate_err (for getdate()) or as the function result (for getdate_r()): 1 The DATEMSK environment variable is not defined, or its value is an empty string. 2 The template file specified by DATEMSK cannot be opened for reading. 3 Failed to get file status information. 4 The template file is not a regular file. 5 An error was encountered while reading the template file. 6 Memory allocation failed (not enough memory available). 7 There is no line in the file that matches the input. 8 Invalid input specification. ENVIRONMENT
DATEMSK File containing format patterns. TZ, LC_TIME Variables used by strptime(3). ATTRIBUTES
Multithreading (see pthreads(7)) The getdate() function is not thread-safe. The getdate_r() function is thread-safe. CONFORMING TO
POSIX.1-2001. NOTES
The POSIX.1-2001 specification for strptime(3) contains conversion specifications using the %E or %O modifier, while such specifications are not given for getdate(). In glibc, getdate() is implemented using strptime(3), so that precisely the same conversions are supported by both. EXAMPLE
The program below calls getdate() for each of its command-line arguments, and for each call displays the values in the fields of the returned tm structure. The following shell session demonstrates the operation of the program: $ TFILE=$PWD/tfile $ echo '%A' > $TFILE # Full weekday name $ echo '%T' >> $TFILE # ISO date (YYYY-MM-DD) $ echo '%F' >> $TFILE # Time (HH:MM:SS) $ date $ export DATEMSK=$TFILE $ ./a.out Tuesday '2009-12-28' '12:22:33' Sun Sep 7 06:03:36 CEST 2008 Call 1 ("Tuesday") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 9 tm_mon = 8 tm_year = 108 tm_wday = 2 tm_yday = 252 tm_isdst = 1 Call 2 ("2009-12-28") succeeded: tm_sec = 36 tm_min = 3 tm_hour = 6 tm_mday = 28 tm_mon = 11 tm_year = 109 tm_wday = 1 tm_yday = 361 tm_isdst = 0 Call 3 ("12:22:33") succeeded: tm_sec = 33 tm_min = 22 tm_hour = 12 tm_mday = 7 tm_mon = 8 tm_year = 108 tm_wday = 0 tm_yday = 250 tm_isdst = 1 Program source #define _GNU_SOURCE 500 #include <time.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { struct tm *tmp; int j; for (j = 1; j < argc; j++) { tmp = getdate(argv[j]); if (tmp == NULL) { printf("Call %d failed; getdate_err = %d ", j, getdate_err); continue; } printf("Call %d ("%s") succeeded: ", j, argv[j]); printf(" tm_sec = %d ", tmp->tm_sec); printf(" tm_min = %d ", tmp->tm_min); printf(" tm_hour = %d ", tmp->tm_hour); printf(" tm_mday = %d ", tmp->tm_mday); printf(" tm_mon = %d ", tmp->tm_mon); printf(" tm_year = %d ", tmp->tm_year); printf(" tm_wday = %d ", tmp->tm_wday); printf(" tm_yday = %d ", tmp->tm_yday); printf(" tm_isdst = %d ", tmp->tm_isdst); } exit(EXIT_SUCCESS); } SEE ALSO
time(2), localtime(3), setlocale(3), strftime(3), strptime(3) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2013-06-21 GETDATE(3)
All times are GMT -4. The time now is 08:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy