Sponsored Content
Full Discussion: Search and assign using sed
Top Forums Shell Programming and Scripting Search and assign using sed Post 302456274 by pattu on Thursday 23rd of September 2010 07:57:44 PM
Old 09-23-2010
Quote:
Originally Posted by danmero
Why sed only, is this a homework ? .. anyway
Code:
var=$(sed '/address1/s/.*=\(.*\)/\1/p;d' file)



---------- Post updated at 07:43 PM ---------- Previous update was at 07:34 PM ----------

hmm... I didn't seen that you are open for other solution.
Shell only:
Code:
pattern=address1
var=""
while IFS=\= read pat adr
do 
    case $pat in 
        $pattern ) var=$adr;break;;
    esac
done< file
echo $var

Thanks a lot man.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search file for word, then assign to variable

Hi all, Trying to search a file for one word only, then assign that word to a variable. Not sure if this is a grep or awk (or either) function. Should be a simple operation. Example: This file contains the string "COMPLETE". I would like to pull that word out and assign it to a... (2 Replies)
Discussion started by: dejit
2 Replies

2. Shell Programming and Scripting

assign subst|grep|sed command result to a variable

Hi, I'm quite new to scripting and I want to modify following line of an existing script: MYVAR=`subst |grep 'L:\\\:' | sed -e 's/.*\\\//'`; What I have to do is to use the content of a variable instead of the constant expression 'L:\\\:' as the grep string to be matched. Assuming I already... (5 Replies)
Discussion started by: snowbiker99
5 Replies

3. Shell Programming and Scripting

How to assign value to a variable with row(using -n) returned by sed

Hi Friends, REQUIREMENT: Want to delete files from the current directory match with the same in the file test.txt set -x i=1 echo "i=$i" COUNT=`sed -n '$=' test.txt` echo "Count=$COUNT" while do "## Here is error##" FILETOREMOVE=`sed -n \'$i,1p\' test.txt` echo $FILETOREMOVE... (5 Replies)
Discussion started by: sourabhsharma
5 Replies

4. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

5. Shell Programming and Scripting

How to assign the Pattern Search string as Input Variable

guys, I need to know how to assing pattern matched string as an input command variable. Here it goes' My script is something like this. ./routing.sh <Server> <enable|disable> ## This Script takes an input <Server> variable from this line of the script ## echo $1 | egrep... (1 Reply)
Discussion started by: raghunsi
1 Replies

6. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

7. Shell Programming and Scripting

Running a program multiple times to search pattern and assign structure

Hi all, I have a big file (n.txt) with following pattern: ATOM 1 N SER A 1 122.392 152.261 138.190 1.00 0.00 N ATOM 2 CA SER A 1 122.726 151.241 139.183 1.00 0.00 C TER ENDMDL ATOM 1 N SER A 1 114.207 142.287 135.439 1.00 0.00 ... (3 Replies)
Discussion started by: bioinfo
3 Replies

8. Shell Programming and Scripting

Trim sed output & assign to variable

Hi, I have the following command that parses an xml file to read a node <port>'s value. Hoever the output comes with spaces. My requirement is to trim the spaces around the value and assign to a variable. sed -n 's|<port>\(.*\)</port>|\1|p' ../cfg.xml How do I go about it? (6 Replies)
Discussion started by: sai2013
6 Replies

9. Shell Programming and Scripting

Regex in sed to find specific pattern and assign to variable

(5 Replies)
Discussion started by: radioactive9
5 Replies

10. UNIX for Beginners Questions & Answers

sed search

Hello, I know how to use sed for simple search but i need to search something like below in a file. From the below string, i need to find and replace only ./ with a $ using sed. ./abcd/str.xyz Thanks in advance KK (8 Replies)
Discussion started by: Pavan Kumar19
8 Replies
TK_BRIEF(1)						      General Commands Manual						       TK_BRIEF(1)

 November 2000" "tk_Brief "

NAME
tk-Brief is a graphical user interface for writing single or multiple letters with latex. Even begginers are able to use it without a long time of learning. SYNOPSIS
tk_Brief [ -a an ] [ -N name ] [ -str street ] [ -o city ] [ -dir directory ] [ -fax faxnumber ] [ -h ] [ filename ] DESCRIPTION
tk_Brief generates a <filename>.tex file using a <filename>.text file and the input from the input fields. There are different letter styles inplemented, e.g. g-brief. Although it was originally written for the german letter norm, it can create an english or durch letter style. The labels can occur in English of Dutch language. tk_Brief is written in Tcl/Tk and therefor available on many platforms. OPTIONS
-h Short Help for tk_Brief. -a to Commandline option for 'to' field. -N name Commandline option for 'name field. -str street Commandline option dor 'street' field. -o city Commandline option for the 'city' field. -dir directory Starting directory. -fax faxnumber Commandline option for the 'faxnumber' field.. BUTTONS
Exit Exits tk_Brief and saves configurations in ${HOME}/.serienbrief Configuration Here are the senders and the layout for the letter style configured. Edit Text Using the external editor (default 'jed') edits the letter test and is saved in the file <filename>.text. Spell checking Using the configured spell checker (default 'ispell') <filename>.text is checked. TeX-file The LaTeXfile can be observed. Latex Compiling the File. Preview Compiling the file and viewing it with the configured viewer (default 'xdvi'). Print Compiling the file and printing it with the configured print command (default 'lpr -Plaser'). Multiple letters tk_Brief enteres multiple letter mode. Send fax Converting the file into g3 and send the fax using sendfax. Clear All temporary files are deleted. MULTIPLE LETTERS
In multiple letter mode input the addresses using 'Edit Addresses' in the following format: <to>;<name: >;<street>;<PLZ Ort>[;<opening>] <to>;<name: >;<street>;<PLZ city>[;<opening>] <to>;<name: >;<street>;<PLZ city>[;<opening>] <to>;<name: >;<street>;<PLZ city>[;<opening>] into the file <filename>.adresses. tk_Brief formats the addresses and saves them into <filename>.adr_ok. The <filename>.tex files are generated using the addresses. <opening> is optional. 'Preview' and 'Print' enters a warning mode because of the number of files. 'q' exits 'xdvi'. The next file is shown. For the later printing 'Generate PostScript' can be used. The PostScript files are numbered <filename><NR>.ps. REQUIREMENTS
g-brief pslatex tcl/tk FILES
$HOME/.serienbrief configuration file for tk_Brief <filename>.text letter text <filename>.tex generated LaTeXfile <filename>.adresses address file for multiple letters <filename>.adr_ok formatted address file for multiple letters SEE ALSO
LaTeX, dvips (1), ispell (1), lpr (1), sendfax (1), gs (1) LICENSE
Copyright (C) 1998 [Ralf Muller] This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. AUTHOR
Ralf Muller Ruppurrer StraBe 104 D-76137 Karlsruhe Email: ralf@krisralf.physik.uni-karlsruhe.de WWW: http://krisralf.physik.uni-karlsruhe.de/tk_Brief 13 TK_BRIEF(1)
All times are GMT -4. The time now is 04:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy