Filtering multiple files with variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filtering multiple files with variables
# 8  
Old 03-09-2009
well, the problem is definitely the \r. Change the sed command to:

Code:
tag=`sed -n '/Tag=/ s/^.*Tag=\([0-9a-zA-Z]*\)/\1/p'  /tmp/resA-$$`

Now the tag must be alphanumeric.

Last edited by otheus; 03-09-2009 at 11:57 AM.. Reason: missed *
# 9  
Old 03-09-2009
problem seems to be in section where we filter the variable, I have tried to move set -x before we set the variable and get:
Code:
++ sed -n '/Tag=/ s/^.*Tag=//p' /tmp/resA-8849
+ tag=$'68722\r'

# 10  
Old 03-09-2009
Ah, sed should quit once it's done. Okay, how about:
Code:
tag=`sed -n '/Tag=/ {s/^.*Tag=\([0-9a-zA-Z]*\).*/\1/p;q}'  /tmp/resA-$$`

Note the changes in bold

Last edited by otheus; 03-09-2009 at 12:07 PM.. Reason: color
# 11  
Old 03-09-2009
oh man,
that's perfect,
I am about to write my first script thanks to you! Smilie

Now I need just figure out your magic tricks with sed command to filter other variables.

I am pretty sure there will be something I'd like to improve so I will post it here later.

Thank you again otheus
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Generate files and use csv data to replace multiple variables in a template

I have a source csv file consists of first field as variable name, and the rest are site-specific information (converted from excel file, where site -specific values in columns). I am trying to create a file for every site using a template and replace the multiple variables with values from the... (3 Replies)
Discussion started by: apalex
3 Replies

2. UNIX for Dummies Questions & Answers

Read in Multiple log files and output selected variables and values to cvs file

I have several problems with my problems: I hope you can help me. 1) the If else statement I am getting an error message. My syntax must be incorrect because the entire statement is throwing an error. For example in filew.log if these items don't exist Memsize, SASFoundation and also if... (0 Replies)
Discussion started by: dellanicholson
0 Replies

3. Shell Programming and Scripting

Reading multiple values from multiple lines and columns and setting them to unique variables.

Hello, I would like to ask for help with csh script. An example of an input in .txt file is below, the number of lines varies from file to file and I have 2 or 3 columns with values. I would like to read all the values (probably one by one) and set them to independent unique variables that... (7 Replies)
Discussion started by: FMMOLA
7 Replies

4. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

5. Shell Programming and Scripting

Awk/sed : help on:Filtering multiple lines to one:

Experts Good day, I want to filter multiple lines of same error of same day , to only 1 error of each day, the first line from the log. Here is the file: May 26 11:29:19 cmihpx02 vmunix: NFS write failed for server cmiauxe1: error 5 (RPC: Timed out) May 26 11:29:19 cmihpx02 vmunix: NFS... (4 Replies)
Discussion started by: rveri
4 Replies

6. UNIX for Advanced & Expert Users

Renaming Multiple Files that have variables in the name

I am trying to rename multiple files from lower case to upper case, but then I need to change the word SHIP to Ship and CSV to csv. This is a sample of the input file name input_file_ship_1234_20110106.csv I need this to look like this INPUT_FILE_Ship_1234_20110106.csv this is the result when I... (3 Replies)
Discussion started by: cventura
3 Replies

7. Shell Programming and Scripting

Filtering Multiple variables from a single column

Hi, I am currently filtering a file, "BUILD_TIMES", that has multiple column of information in it. An example of the data is as follows; Fri Nov 5 15:31:33 2010 00:28:17 R7_BCGNOFJ_70.68 Fri Nov 5 20:57:41 2010 00:07:21 R7_ADJCEL_80.6 Wed Nov 10 17:33:21 2010 00:01:13 R7_BCTTEST3_80.1X... (7 Replies)
Discussion started by: crunchie
7 Replies

8. Shell Programming and Scripting

Filtering issues with multiple columns in a single file

Hi, I am new to unix and would greatly appreciate some help. I have a file containing multiple colums containing different sets of data e.g. File 1: John Ireland 27_December_69 Mary England 13_March_55 Mike France 02_June_80 I am currently using the awk... (10 Replies)
Discussion started by: crunchie
10 Replies

9. Shell Programming and Scripting

Filtering multiple entries in a file

Hi, I have a requirement to filter multiple entries in a text file. Entries are a pair of 2 lines .Like line1 line2 ....... ........ Here line1, line2 consist of one pair. line1 and line2 contain different data. There can be multiple entries for the same pair. And there can be 'n' such... (2 Replies)
Discussion started by: suman_jakkula
2 Replies
Login or Register to Ask a Question