Sponsored Content
Top Forums Shell Programming and Scripting Print String Every Specific Line Post 302766547 by Don Cragun on Tuesday 5th of February 2013 02:25:01 AM
Old 02-05-2013
Quote:
Originally Posted by pamu
Or sth like this..

Code:
 
awk 'BEGIN{split("DD AA BB CC",P)}
{print P[NR%4+1],$0}' file

Not quite. In awk, + has higher precedence than % (so you're doing mod 5 rather than (mod 4) + 1). If you change the subscript in the 2nd line to (NR%4)+1, you'd get what you wanted.

-------------------------------------
Ouch... I apologize. I was looking at unary + not binary +. Pamu's code is correct as written.

Sorry,
Don
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print lines with search string at specific position

Hi Folks, I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas? ... (4 Replies)
Discussion started by: HealthyGuy
4 Replies

2. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

3. Shell Programming and Scripting

search a word and print specific string using awk

Hi, I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies

4. Shell Programming and Scripting

Select a specific part of the string and print it

Hi all, I have a string that looks like: #!/bin/sh options="arguments: --user=alpha --group=beta --prefix=/usr/share --proxy-path=/proxy --proxy-tmp=/tmp --conf-path=/etc" My goal is to transform the string into an array, then for each key, if it starts with "--proxy" to print the string... (2 Replies)
Discussion started by: TECK
2 Replies

5. Shell Programming and Scripting

search-word-print-specific-string

Hi, Our input xml looks like: <doc> <str name="account_id">1111</str> <str name="prd_id">DHEP155EK</str> </doc> - <doc> <str name="account_id">6666</str> <str name="prd_id">394531662</str> </doc> - <doc> <str name="account_id">6666</str> <str... (1 Reply)
Discussion started by: Jassz
1 Replies

6. Shell Programming and Scripting

Need awk help to print specific columns with as string in a header

awk experts, I have a big file of 4000 columns with header. Would like to print the columns with string value of "Commands" in header. File has "," separator. This file is on ESX host with Bash. Thanks, Arv (21 Replies)
Discussion started by: arv_cds
21 Replies

7. Shell Programming and Scripting

break the string and print it in a new line after a specific word

Hi Gurus I am new to this forum.. I am using HP Unix OS. I have one single string in input file as shown below Abc123 | cde | fgh | ghik| lmno | Abc456 |one |two |three | four | Abc789 | five | Six | seven | eight | Abc098 | ........ I want to achive the result in a output file as shown... (3 Replies)
Discussion started by: kannansr621
3 Replies

8. UNIX for Dummies Questions & Answers

How to Detect Specific Pattern and Print the Specific String after It?

I'm still beginner and maybe someone can help me. I have this input: the great warrior a, b, c and what i want to know is, with awk, how can i detect the string with 'warrior' string on it and print the a, b, and c seperately, become like this : Warrior Type a b c Im still very... (3 Replies)
Discussion started by: radynaraya
3 Replies

9. Shell Programming and Scripting

awk - how to print specific field if a string is matched

hi gurus, I would like to be able to use awk to process 1 file as such: abc 1 2 3 4 5 6 7 8 9 10 flags 1 2 4 flags 1 2 5 abc 2 3 4 5 6 7 8 9 10 11 flags 1 2 3 abc 4 5 6 7 8 9 6 7 78 89 flags 1 2 3 flags 1 2 4 flags 1 2 3 4 I would like to be able to print field 1 and 5 when the... (4 Replies)
Discussion started by: revaroo
4 Replies

10. Shell Programming and Scripting

awk to print string if tag is specific value

In the below awk I am trying to print expName only if another tag planExecuted is true. In addition to the expName I am also printing planShortID. For some reason the word experiment gets printed so I remove it with sed. I have attached the complete index.html as well as included a sample of it... (1 Reply)
Discussion started by: cmccabe
1 Replies
ZOOMER(1)						      General Commands Manual							 ZOOMER(1)

NAME
zoomer -- generate a video from a picture by zooming from one point to another SYNOPSIS
zoomer options... DESCRIPTION
zoomer automatically generates a video from a picture. It starts at the full picture and then zooms into the first point. Then zooms out and into the next point, etc. At the moment of reaching a point, zoomer will write a text (e.g. a name). zoomer needs a picture (bigger is better) and a data file to define the points to be zoomed into. OPTIONS
--data the data file setting the details to be zoomed. --debug show a verbose output --frames-moveing how many frames between details --frames-stoped how many frames focused on the detail --font-size the size of the text --output the name of the output video --pic the name of the input picture (bigger is better) --replace-output will automaticaly delete a file with the same output name --use-zenity will show a nice graphical progress bar --video-size the video resolution in the WxH notation like 480x360 THE DATA FILE
The data file is a simple text file to provide informaton about where zoomer must zoom. There must be one line by detail and no other information. The zoomer don't supports empty lines or commentaries. The detail line has the pattern: X,Y Width Text See a data example: 364,178 57 Bart 233,246 62 Lisa 396,274 52 Maggie 302,059 61 Marge 228,130 66 Homer The Width is the with of the soom square. The Height will be ever proporcional to the output setted height. AUTHOR
This manual page was written by Aurelio A. Heckert aurium@gmail.com for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 any later version pub- lished by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/. ZOOMER(1)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy