Sponsored Content
Full Discussion: grep help after context
Top Forums Shell Programming and Scripting grep help after context Post 302419782 by pseudocoder on Saturday 8th of May 2010 04:34:28 PM
Old 05-08-2010
Not sure if this is what you want...

ftpdata
Code:
FILE_ID=1
FILE_FTP_ID=ftp.server1.com
FILE_FTP_USER=user1
FILE_FTP_PASS=pass1
 
FILE_ID=2
FILE_FTP_ID=ftp.server2.com
FILE_FTP_USER=user2
FILE_FTP_PASS=pass2
FILE_FTP_PARAM_1=param1
FILE_FTP_PARAM_2=param2
 
FILE_ID=3
FILE_FTP_ID=ftp.server3.com
FILE_FTP_USER=user3
FILE_FTP_PASS=pass3
FILE_FTP_VALUE_1=val1
FILE_FTP_VALUE_2=val2
FILE_FTP_VALUE_3=val3
 
FILE_ID=4
FILE_FTP_ID=ftp.server4.com
FILE_FTP_USER=user4
FILE_FTP_PASS=pass4

getdata.sh
Code:
#!/bin/sh

string="FILE_ID=$1"

sed -n '/'$string'/,/^ /p;' ftpdata | sed '$d'

Code:
$ ./getdata.sh 1
FILE_ID=1
FILE_FTP_ID=ftp.server1.com
FILE_FTP_USER=user1
FILE_FTP_PASS=pass1
$ ./getdata.sh 2
FILE_ID=2
FILE_FTP_ID=ftp.server2.com
FILE_FTP_USER=user2
FILE_FTP_PASS=pass2
FILE_FTP_PARAM_1=param1
FILE_FTP_PARAM_2=param2
$ ./getdata.sh 3
FILE_ID=3
FILE_FTP_ID=ftp.server3.com
FILE_FTP_USER=user3
FILE_FTP_PASS=pass3
FILE_FTP_VALUE_1=val1
FILE_FTP_VALUE_2=val2
FILE_FTP_VALUE_3=val3
$ ./getdata.sh 4
FILE_ID=4
FILE_FTP_ID=ftp.server4.com
FILE_FTP_USER=user4
FILE_FTP_PASS=pass4
$


Last edited by pseudocoder; 05-08-2010 at 05:41 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

Context Free Grammar

Hi Folks, I am trying to write a small compiler for syntax checking in C programs. I would like to attach a Context Free Grammar(CFC) to it. Does any one know as to how I should associate or map the Grammar with the C program???? A quick help would help me a lot...... Thanks, Nisha (4 Replies)
Discussion started by: Nisha
4 Replies

2. UNIX for Advanced & Expert Users

Context Switching

I know that this is a relative question but can someone give me an idea of what would be considered a high number of context switches? I am running vmstat and show a cs value of between 5000 and 6000 on a 4 processor system. How can I deduce if this number is high or not? Also, the timeslice... (2 Replies)
Discussion started by: keelba
2 Replies

3. Shell Programming and Scripting

keep context in awk

here is a data file. ------------------------------------- KSH, CSH, BASH, PERL, PHP, SED, AWK KSH, CSH, BASH, PERL, PHP, BASH, PERL, PHP, SED, AWK CSH, BASH, PERL, PHP, SED, KSH, CSH, BASH, PERL, PHP, SED, AWK ------------------------------------- My desired output is... (2 Replies)
Discussion started by: VTAWKVT
2 Replies

4. UNIX for Advanced & Expert Users

context lost problem

there are several same servers(process) on more than one server(machine) providing the same service. we store session/context within the server(process), if the same client login, he will be directed to the very server service for him last time. But, if a server(machine or process) down, the... (1 Reply)
Discussion started by: zhongyj
1 Replies

5. Homework & Coursework Questions

Context-switching - vmstat

1. The problem statement, all variables and given/known data: Type `vmstat -s; vmstat -n 1 5; vmstat -n 1 5; vmstat -s` to your Ruby interpreter. Then terminate your Ruby session. Run the Unix com- mand vmstat -s; vmstat -n 1 5; vmstat -s in the same terminal window you had been using for... (2 Replies)
Discussion started by: snowboarder
2 Replies

6. Slackware

Context dependent symlinks

Ive got multiple PCs, sharing an NFS mounted home dir. For certain apps I would like to keep the config files host specific. Easy solution is to create symlinks to local folders for configs. Ideally I would still want the .config files to reside in the user home folder. Is it possible to... (2 Replies)
Discussion started by: agentrnge
2 Replies

7. Shell Programming and Scripting

Grep multiple search terms with context

I have a file that is a sort library in the format: ##def title1 content1 stuff1 content2 stuff2 ##enddef ##def title2 etc.. I want to grep def and content and pull some trailing context from content so the result would look something like: (1 Reply)
Discussion started by: Moe.Wilensky
1 Replies

8. UNIX for Dummies Questions & Answers

Regarding context to add in a file

Hi Folks, I have one query is that I can reach to a location of a file named Integration_Config_3.properties through putty cd /usr/local/pos/jlan/config/byStore/il ls -ltr I can open this file in vi editior also vi Integration_Config_3.properties But now my query is I want to add the... (3 Replies)
Discussion started by: SankalpS
3 Replies

9. UNIX for Advanced & Expert Users

Interupt Context Switching

If suppose a middle level interrupt is being serviced and a high priority interrupts comes in then in that case what all process will take place. The interrupt context switch will happen. But where will the interrupt context be saved? Is there something called as part process data area? (4 Replies)
Discussion started by: rupeshkp728
4 Replies

10. Shell Programming and Scripting

Questions related to if in awk context and if without awk context

I wrote this code, questions follow #! /bin/bash -f # Purpose - to show how if syntax is used within an awk clear; ls -l; echo "This will print out the first two columns of the inputted file in this directory"; echo "Enter filename found in this directory"; read input; ... (11 Replies)
Discussion started by: Seth
11 Replies
ftp::geturl(n)							    ftp client							    ftp::geturl(n)

__________________________________________________________________________________________________________________________________________________

NAME
ftp::geturl - Uri handler for ftp urls SYNOPSIS
package require Tcl 8.2 package require ftp::geturl ?0.2.1? ::ftp::geturl url _________________________________________________________________ DESCRIPTION
This package provides a command which wraps around the client side of the ftp protocol provided by package ftp to allow the retrieval of urls using the ftp schema. API
::ftp::geturl url This command can be used by the generic command ::uri::geturl (See package uri) to retrieve the contents of ftp urls. Internally it uses the commands of the package ftp to fulfill the request. The contents of a ftp url are defined as follows: file The contents of the specified file itself. directory A listing of the contents of the directory in key value notation where the file name is the key and its attributes the asso- ciated value. link The attributes of the link, including the path it refers to. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category ftp of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
ftpd, mime, pop3, smtp KEYWORDS
ftp, internet, net, rfc 959 CATEGORY
Networking ftp 0.2.1 ftp::geturl(n)
All times are GMT -4. The time now is 08:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy