Sponsored Content
Full Discussion: [code] Automatic File Input
Top Forums Shell Programming and Scripting [code] Automatic File Input Post 302374660 by Maruti on Wednesday 25th of November 2009 07:23:22 AM
Old 11-25-2009
[code] Automatic File Input

i have got many files like this in my folder temp(say)
imp_02042008.txt for date 02-04-2008
imp_03092009.txt for date 03-09-2009
imp_25112009.txt for date 25-11-2009
...................
........

in some folder.
and one of my shell code uses one of the above files based on date.
for example for todays date it should pick the file imp_25112009.txt
for tomorrows date it should pick the file like imp_26112009.txt

My code is like below one:
print substr($1,4,3),"",substr($2,22,8) inputfile.txt>outputfile.txt

This code should run on day to day basis.
What i want is a code to pick up the file (eg..imp_26112009.txt) automatically from folder temp based on day.. i.e, for a given day particular file should be taken as input in my code...
pls help me in this regard..


thread closed.

Continue here: https://www.unix.com/shell-programmin...nput-code.html

Last edited by Neo; 11-25-2009 at 09:04 AM.. Reason: duplicate thread https://www.unix.com/shell-programming-scripting/124568-automatic-file-input-code.html
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Automatic input to commands

Hi, In a shell script i am running a command which is asking for input. How can i give that automatically. I have done this before but for the time being can't recall. Was something like <| Thanks (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

2. Shell Programming and Scripting

Automatic file input to code

i have got many files like this in my folder temp(say) imp_02042008.txt for date 02-04-2008 imp_03092009.txt for date 03-09-2009 imp_25112009.txt for date 25-11-2009 ................... ........ in some folder. and one of my shell code uses one of the above files based on date.... (9 Replies)
Discussion started by: Maruti
9 Replies

3. Shell Programming and Scripting

Help to write a script or program to automatic execute and link input file data

Output file template format <input_file_name>a</input_file_name> <total_length_size>b</total_length_size> <log_10_length_size>c</log_10_length_size> Input_file_1 (eg. sample.txt) SDFSDGDGSFGRTREREYWW Parameter: a is equal to the input file name b is equal to the total length of... (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. UNIX for Dummies Questions & Answers

12. If an ‘88’ Record with BAI Code ‘902’ was found on input file and not written to Output file, re

This is my input file like this 03,105581,,015,+00000416418,,,901,+00000000148,,,922,+00000000354,,/ 49,+00000000000416920,00002/ 03,5313236,,015,+00231036992,,,045,+00231036992,,,901,+00000048428,,/ 88,100,+0000000000000,0000000,,400,+0000000000000,0000000,/ 88,902,+0000000079077,,/... (0 Replies)
Discussion started by: sgoud
0 Replies

5. Shell Programming and Scripting

Giving automatic multiple Input to a tool from shell script

Hi, Please help me,its urgent. I have a tool that i want to run from a shell script. When we run the tool it will ask the user choice to add or delete. When user enter the choice it will then ask how many units he want to delete or add and will add or delete accordingly. Now I want to... (1 Reply)
Discussion started by: saket18@ymail.c
1 Replies

6. Shell Programming and Scripting

Automatic Input to a command

Hi, I have an issue where i run an command in a shell script. command >/dev/null ret=$? echo ret If the command returns an error i'm redirecting it to /dev/null. The prob is if an error comes it expects the user to press return to continue. And hence the return is not echoed. and the end... (4 Replies)
Discussion started by: subhrap.das
4 Replies

7. Shell Programming and Scripting

[KSH] Creating automatic variable from read input

Hello there, I am posting to seek help with a KSH script, I am making a simple calculation program where the user can enter as many numbers as they like, I am getting their input using the read command, however I am not sure how to repeat doing this and storing the input in to new variables... (7 Replies)
Discussion started by: pandapowerbox
7 Replies

8. UNIX for Dummies Questions & Answers

[Solved] How to refer to input file in code?

This may be a dumb question, but googling is not giving me an answer. I'm trying to figure out how to refer to an input file in my code. Lets say i run a script in bash: "sh shellscript.sh inputfile" (Inputfile will be variable...whatever file i run the script on) I wanted to make... (5 Replies)
Discussion started by: legato22
5 Replies

9. Shell Programming and Scripting

Automatic input "yes" in a shell script

Hi All, I need a favour. I have a file called "redhat_servers.txt" containing some server names line by line. When I try to ssh to each server, and I have already done with ssh key-gen stuff. Now, for first time if I do ssh .. I need to type yes I have more than 400 servers...it will take... (4 Replies)
Discussion started by: kumar85shiv
4 Replies

10. UNIX for Beginners Questions & Answers

Help with the code to do automatic task in plink

Hi, I am newbie tothis forum and also to unix. i wa shownt help in giving me a acceptable code so that i could add it as batch to be included in the task scheduler. i use plink and putty to login to my router. With this i get to the $, linux prompt there i have to issue a command show... (5 Replies)
Discussion started by: jraju
5 Replies
SHTOOL-MDATE.TMP(1)					      GNU Portable Shell Tool					       SHTOOL-MDATE.TMP(1)

NAME
shtool-mdate - GNU shtool pretty-print last modification time SYNOPSIS
shtool mdate [-n|--newline] [-z|--zero] [-s|--shorten] [-d|--digits] [-f|--field-sep str] [-o|--order spec] path DESCRIPTION
This command pretty-prints the last modification time of a given file or directory path, while still allowing one to specify the format of the date to display. OPTIONS
The following command line options are available. -n, --newline By default, output is written to stdout followed by a "newline" (ASCII character 0x0a). If option -n is used, this newline character is omitted. -z, --zero Pads numeric day and numeric month with a leading zero. Default is to have variable width. -s, --shorten Shortens the name of the month to a english three character abbreviation. Default is full english name. This option is silently ignored when combined with -d. -d, --digits Use digits for month. Default is to use a english name. -f, --field-sep str Field separator string between the day month year tripple. Default is a single space character. -o, --order spec Specifies order of the day month year elements within the tripple. Each element represented as a single character out of ``"d"'', ``"m"'' and ``"y"''. The default for spec is ``"dmy"''. EXAMPLE
# shell script shtool mdate -n / shtool mdate -f '/' -z -d -o ymd foo.txt shtool mdate -f '-' -s foo.txt HISTORY
The GNU shtool mdate command was originally written by Ulrich Drepper in 1995 and revised by Ralf S. Engelschall <rse@engelschall.com> in 1998 for inclusion into GNU shtool. SEE ALSO
shtool(1), date(1), ls(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-MDATE.TMP(1)
All times are GMT -4. The time now is 08:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy