Sponsored Content
Top Forums Shell Programming and Scripting Outputting Results to Indexed List Post 302914910 by Don Cragun on Thursday 28th of August 2014 07:02:49 PM
Old 08-28-2014
Maybe you can find something useful in this example:
Code:
#!/bin/ksh
IAm=${0##*/}
tf="/tmp/$IAm.$$"
trap 'rm -f "$tf"' EXIT
find . -type f > "$tf"
nl "$tf"
printf 'Enter number of file to process or 0 to exit: '
read -r line
if [ "$line" == 0 ] || [ "$line" == "" ]
then	exit 0
fi
if [ "$line" != "${line#*[^0-9]}" ]
then	printf '%s: Response must be numeric.\n' "$IAm" >&2
	exit 1
fi
file=$(sed -n "${line}{p;q;}" < "$tf")
if [ "$file" = "" ]
then	printf '%s: Response out of range.\n' "$IAm" >&2
	exit 2
fi
printf 'Do whatever you want with file: %s\n' "$file"

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

indexed sequential access in c files

hi, I want to implement indexed sequential access method in my flat file, Any idea other than INFORMIX C-ISAM library, because it is not free ware, Any Freeware available? (0 Replies)
Discussion started by: vrkiruba
0 Replies

2. UNIX for Dummies Questions & Answers

List grep results

Hi I need to search for matching strings in a database and I want to print out all files that matches in "detail", which means that I want the output to contain datum of last saving. I only get the grep function tp print the actual file names which is not enough since the database is to large... (14 Replies)
Discussion started by: slire
14 Replies

3. Shell Programming and Scripting

filtering list results

I created a large file list using: find . -type f -mtime +540 > test2.txt ..which searched recursively down the directory tree searching for any file older than 540 days. I would like to filter the results removing the directory name and the "/" character, resulting in only a list of the... (3 Replies)
Discussion started by: fxvisions
3 Replies

4. Shell Programming and Scripting

outputting data in table from grep results

Hi all. I'm a real unix newbie and looking for some help on a shell scripting problem. I'm going the longest ways around everything but I'm getting there. My next problem however has me stumped. I have set up a program that takes inputs from a user for a particular month and year (and stores them... (2 Replies)
Discussion started by: Chillspark
2 Replies

5. UNIX for Dummies Questions & Answers

getting input, then outputting it

Hi! I am a newbie to Unix. I was writing a little game program for fun when thought of an idea to allow data to be saved. I knew to take all of the Predefined variables and put them into a separate file, then including the file in the program. But I am having trouble making it so that the user... (0 Replies)
Discussion started by: signebedi
0 Replies

6. Shell Programming and Scripting

How to extract data from indexed files (ISAM files) maintained in an unix server.

Hi, Could someone please assist on a quick way of How to extract data from indexed files (ISAM files) maintained in an UNIX(AIX) server.The file data needs to be extracted in flat text file or CSV or excel format . Usually we have programs in microfocus COBOL to extract data, but would like... (2 Replies)
Discussion started by: devina
2 Replies

7. Shell Programming and Scripting

Multiple indexed conditions with ksh

Dear Unix Experts, I have randomly generated the x, y, and z coordinates of 16 atoms of two species, A and B (8 atoms each) Then I calculated the spacing between all the A atoms labeled d1, B atoms labeled d2 and between A and B atoms labeled d3. I would like to save the x, y, z coordinates to... (1 Reply)
Discussion started by: vahid
1 Replies

8. Shell Programming and Scripting

Can ctag and cscope support recording search results and displaying the history results ?

Hello , When using vim, can ctag and cscope support recording search results and displaying the history results ? Once I jump to one tag, I can use :tnext to jump to next tag, but how can I display the preview search result? (0 Replies)
Discussion started by: 915086731
0 Replies

9. Shell Programming and Scripting

Replace string in a file with some content indexed from another file.

We have two files file 1: (usually small, ~100 lines), each line contains a : separated index, value e.g 2: Apple 1: Banana 5: Pear 7: Orange File 2: (usually large, 10 million lines or more), each line contains a single string value. e.g xyz1 xyz2 xyz3 xyz4 xyz5 xyz6 xyz7 Now... (2 Replies)
Discussion started by: AlokKumbhare
2 Replies

10. Shell Programming and Scripting

Search for names in one list in another and print results

Hi All , New to the Bash / Shell programming world and looking for some help I have two files 1: Contains a list of names : eg STEVE BOB CRAIG 2: Contains information with those included names but also others that are not in the list (1 Reply)
Discussion started by: Lonerg550
1 Replies
PRINTF(1)								FSF								 PRINTF(1)

NAME
printf - format and print data SYNOPSIS
printf FORMAT [ARGUMENT]... printf OPTION DESCRIPTION
NOTE: your shell may have its own version of printf which will supercede the version described here. Please refer to your shell's documen- tation for details about the options it supports. Print ARGUMENT(s) according to FORMAT. --help display this help and exit --version output version information and exit FORMAT controls the output as in C printf. Interpreted sequences are: " double quote NNN character with octal value NNN (0 to 3 digits) \ backslash a alert (BEL)  backspace c produce no further output f form feed new line carriage return horizontal tab v vertical tab xNNN byte with hexadecimal value NNN (1 to 3 digits) uNNNN character with hexadecimal value NNNN (4 digits) UNNNNNNNN character with hexadecimal value NNNNNNNN (8 digits) %% a single % %b ARGUMENT as a string with `' escapes interpreted and all C format specifications ending with one of diouxXfeEgGcs, with ARGUMENTs converted to proper type first. Variable widths are han- dled. AUTHOR
Written by David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for printf is maintained as a Texinfo manual. If the info and printf programs are properly installed at your site, the command info printf should give you access to the complete manual. GNU coreutils 4.5.3 February 2003 PRINTF(1)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy