Sponsored Content
Top Forums Shell Programming and Scripting How to set mutliple words variable from command line Post 302369319 by frans on Saturday 7th of November 2009 01:02:32 PM
Old 11-07-2009
Something like that ? (bash shell, can be translated)
Code:
#!/bin/bash
if [ ${#@} = 0 ]
then
  echo "error no arguments" # or anything else
else
     PATTERN=$1
     if [ ${#@} = 1  ]
     then
          read -p "Enter name(s) of files (separated by spaces and delimited wit quotes if containing spaces)" FILES
     else
          shift
          FILES="$@"
     fi
fi
for FILE in $FILES
do
     # what you want to do with each file i.e. :
     grep $PATTERN $FILES
done

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Export command giving Variable Name vs the Value set for the Variable

I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so: set -a export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data" export... (2 Replies)
Discussion started by: ParNone
2 Replies

2. UNIX for Dummies Questions & Answers

Identify duplicate words in a line using command

Hi, Let me explain the problem clearly: Let the entries in my file be: lion,tiger,bear apple,mango,orange,apple,grape unix,windows,solaris,windows,linux red,blue,green,yellow orange,maroon,pink,violet,orange,pink Can we detect the lines in which one of the words(separated by field... (8 Replies)
Discussion started by: srinivasan_85
8 Replies

3. Shell Programming and Scripting

set variable command

Hi all, I want to set a variable in ksh shell (prompt) and echo the value. $ set x=5 $echo $x But it is returning null. Can any one please help. Thanks in advance (1 Reply)
Discussion started by: ammu
1 Replies

4. UNIX for Dummies Questions & Answers

displaying mutliple fields on command line

This is probably the dumbest question you guys can get, but I'm trying, as a complete noob, to display the unix calendar for all the months without Saturday and Sunday showing. How can I remove those fields without having to type all the fields in individually such as: cal -y | awk '{print $2,... (3 Replies)
Discussion started by: Trellot
3 Replies

5. UNIX for Dummies Questions & Answers

overlapping words on command line

i tried resize command , but it's not working...... (4 Replies)
Discussion started by: gaurav123
4 Replies

6. UNIX for Dummies Questions & Answers

how to extend words on a command line ?

within a unix window, how do you setup your session to extend a word, by hitting the "esc" key twice. e.g. ls -la scri (esc key, esc key) thankyou (6 Replies)
Discussion started by: venhart
6 Replies

7. Shell Programming and Scripting

alias two words command line

Hello, i would like to alias aptitude install for sudo aptitude install, is it possible, and how ? i read the man alias page, but i think i have to use something with \ or { but i don't know exactly what. (3 Replies)
Discussion started by: harlock59
3 Replies

8. UNIX for Dummies Questions & Answers

Adding words after a set of words

Greetings. I am a UNIX newbies. I am currently facing difficulties dealing with a large data set and I would like to ask for helps. I have a input file like this: ak 1 AAM1 ak 2 AAM1 ak 3 AAM1 ak 11 AMM2 ak 12 AMM2 ak 13 AMM2 ak 14 AMM2 Is there any possibility for me to... (7 Replies)
Discussion started by: Amanda Low
7 Replies

9. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

10. Shell Programming and Scripting

Print mutliple patterns in a line using sed

Hi, I am trying to print multiple patterns in a line using sed. But it is printing only the last occurance of a pattern. If the line is the the output should be Lookup Procedure|Stored proc But the output I am getting is Stored proc The code I am using is echo... (9 Replies)
Discussion started by: kedar_laveti
9 Replies
LSDIFF(1)																 LSDIFF(1)

NAME
lsdiff - show which files are modified by a patch SYNOPSIS
lsdiff [-n] [-p n] [--strip=n] [--addprefix=PREFIX] [-s] [-i PATTERN] [-x PATTERN] [-v] [file...] lsdiff {--help | --version | --filter ... | --grep ...} DESCRIPTION
List the files modified by a patch. You can use both unified and context format diffs with this program. OPTIONS
-n Display the line number that each patch begins at. If verbose output is requested, each hunk of each patch is listed as well. For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab character, followed by the name of the file that is modified. If -v is given, following each of these lines will be one line for each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string ``Hunk #'', and the hunk number (starting at 1). -p n When matching, ignore the first n components of the pathname. --strip=n Remove the first n components of the pathname before displaying it. --addprefix=PREFIX Prefix the pathname with PREFIX before displaying it. -s Show file additions, modifications and removals. A file addition is indicated by a ``+'', a removal by a ``-'', and a modification by a ``!''. -i PATTERN Include only files matching PATTERN. -x PATTERN Exclude files matching PATTERN. -v Verbose output. --help Display a short usage message. --version Display the version number of lsdiff. --filter Behave like filterdiff(1) instead. --grep Behave like grepdiff(1) instead. SEE ALSO
filterdiff(1), grepdiff(1) EXAMPLES
To sort the order of touched files in a patch, you can use: lsdiff patch | sort -u | xargs -rn1 filterdiff patch -i To show only added files in a patch: lsdiff -s patch | grep '^+' | cut -c2- | xargs -rn1 filterdiff patch -i To show the headers of all file hunks: lsdiff -n patch | (while read n file do sed -ne "$n,$(($n+1))p" patch done) AUTHOR
Tim Waugh <twaugh@redhat.com>. patchutils 13 May 2002 LSDIFF(1)
All times are GMT -4. The time now is 07:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy