Sponsored Content
Top Forums Shell Programming and Scripting Grep correct pattern with special character and variables Post 302845195 by RudiC on Wednesday 21st of August 2013 04:47:10 AM
Old 08-21-2013
Using variables as set in post#1:
Code:
awk -vvar1="$var1" -vvar2="$var2" '$0~(var1"|"var2)"\"$" {print $1,$3,$5}' file
time="08:00" start="left" end="north"
time="12:00" start="right" end="south"
time="10:40" start="top" end="south"
time="09:40" start="down" end="north"
time="13:55" start="left" end="south"

@briandanielz: Read it like: hand over var1 and var2 to awk; if $0 (= entire line) matches var1 OR ( | ) var2, plus double quote at the EOL ( $ ), then print the three fields.

Last edited by RudiC; 08-21-2013 at 05:54 AM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Escaping special character stored in variables : perl

Hi just for regular use i m working on small module written in perl for getting date in specified format like i have to specify date format and then seperator to seperate date i am 95% done. now i m sure explanation i gave is not good enough so i am putting output here : C:\Documents and... (2 Replies)
Discussion started by: zedex
2 Replies

2. UNIX for Advanced & Expert Users

grep in special character

All, I am trying to grep "-----" from a test when i use this i am getting the below error. What is the reason for this ?????... How can i over come this ##) echo "----------------- test_sys_job -----------------" | grep "-----------------" grep: illegal option -- - grep: illegal... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

3. Shell Programming and Scripting

pattern matching on any special character in Unix

Hi, I have field in a file which would come with any special character, how do i check that field? Eg: @123TYtaasa>>>/ 131dfetr_~2 In the above example, how do I add pattern for any special character on the keyboard. Thanks (3 Replies)
Discussion started by: techmoris
3 Replies

4. Linux

how to grep special character regular expression?

Hi :) I have 2 files file1: SNP_A-2208459 SNP_A-4215188 SNP_A-2012248 SNP_A-1882998 file2: CHR SNP UNADJ BONF HOLM * * * etc. 19 SNP_A-2236481 1.742e-26 5.442e-21 13 SNP_A-4204405 8.643e-07 1.505e-06 3 SNP_A-1860908... (11 Replies)
Discussion started by: sogi
11 Replies

5. Shell Programming and Scripting

How to print range of lines using sed when pattern has special character "["

Hi, My input has much more lines, but few of them are below pin(IDF) { direction : input; drc_pinsigtype : signal; pin(SELDIV6) { direction : input; drc_pinsigtype : ... (3 Replies)
Discussion started by: nehashine
3 Replies

6. Shell Programming and Scripting

SED equivalent for grep -w -f with pattern having special characters

I'm looking for SED equivalent for grep -w -f. All I want is to search a list of patterns from a file. Also If the pattern doesn't match I do not want "null returned", rather I would prefer some text as place holder say "BLANK LINE" as I intend to process the output file based on line number. ... (1 Reply)
Discussion started by: novice_man
1 Replies

7. Shell Programming and Scripting

Grep special pattern in 3rd column

I have a file (test.dat) that has this pattern: 1000 000001 (92.431343802235503, 90.0) 1000 000002 (87.568656197764497, 80.0) 1000 000003 (150.75815307316083, 150.0) 1000 000004 (29.241846926839159, 20.0) 1000 000005 (110.02128542766, 110.0) 1000 000006 (69.978714572339996, 60.0) 1000... (8 Replies)
Discussion started by: kayak
8 Replies

8. Linux

Creating 2 variables from a multiple pattern grep

first time poster here Im pretty new to grep and linux in general and I spent pretty much all day yesterday researching and coming up with a grep command to help with my university project. I am attempting to create a proof of concept bash script to scan the network using ngrep, find appropriate... (7 Replies)
Discussion started by: scottish_jason
7 Replies

9. Shell Programming and Scripting

Merging two special character separated files based on pattern matching

Hi. I have 2 files of below format. File1 AA~1~STEVE~3.1~4.1~5.1 AA~2~DANIEL~3.2~4.2~5.2 BB~3~STEVE~3.3~4.3~5.3 BB~4~TIM~3.4~4.4~5.4 File 2 AA~STEVE~AA STEVE WORKS at AUTO COMPANY AA~DANIEL~AA DANIEL IS A ELECTRICIAN BB~STEVE~BB STEVE IS A COOK I want to match 1st and 3rd... (2 Replies)
Discussion started by: crypto87
2 Replies

10. Shell Programming and Scripting

Grep -F for special character

a='CASH$$A' /usr/xpg4/bin/grep -F "$a" *.txt It is not able to grep CASH$$A string as it contains special character $$. I also tried with /usr/xpg4/bin/grep -F '$a' *.txt but still not working. I have to assign CASH$$A to a variable and serach that variable..i dont want to search the... (8 Replies)
Discussion started by: millan
8 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 12:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy