Sponsored Content
Top Forums Shell Programming and Scripting printing strings in one X number of times from another Post 302205913 by dcfargo on Monday 16th of June 2008 01:19:05 PM
Old 06-16-2008
printing strings in one X number of times from another

I have one file of numbers

4
5
2
...

And another file of strings

aaaaa bbbbb
ccccc ddddd
eeeee ffffff
...

I'd like to print the stings from each line in reverse order with some decoration the number of times listed in the first file

such as:

Yeah bbbbb aaaaa
Yeah bbbbb aaaaa
Yeah bbbbb aaaaa
Yeah bbbbb aaaaa
Yeah ddddd ccccc
Yeah ddddd ccccc
Yeah ddddd ccccc
Yeah ddddd ccccc
Yeah ddddd ccccc
Yeah fffff eeeee
Yeah fffff eeeee


I'm trying with:

awk '
NR==FNR{
a[NR]=$0
next
}
{
for(i=1;i<NR;i++)
print "Yeah", $2,$1
}
' filenumbers filestrings > outfile

This isn't working.

Thanks for your help
 

10 More Discussions You Might Find Interesting

1. AIX

Number of login times

Hi! I'm currently using AIX 4.3 and would like to know where can i find to see that there's a restriction on the number of login times a user can have. Example, I want to see whether user A has only 1 login while user B can have 2 logins (without logging off the first one). Would I be able to... (7 Replies)
Discussion started by: ftengcheng
7 Replies

2. UNIX for Dummies Questions & Answers

Counting the number of times a character appears

I am looking for a bash command that counts the number of times a character appears in a file. For example "I am a newbie, trying to learn shell script". Then the command counts the number of e and gives them as 4. Also I want one that counts the number of times a character in a string is replaced.... (2 Replies)
Discussion started by: #moveon
2 Replies

3. Shell Programming and Scripting

printing each line in a file X times

This is probably simple but I would like to print every line in a file 5 times like this: awk 'NR' mens_csv.tab Dub Tank 53%Hemp/42%Cotton/5%Lycra Jersey Dark Green 0 $22.50 Dub Tank 53%Hemp/42%Cotton/5%Lycra Jersey Indigo Blue 0 $22.50 --------------- Dub... (4 Replies)
Discussion started by: Autumn Tree
4 Replies

4. Shell Programming and Scripting

Match and count the number of times

ile1 Beckham Ronaldo file2 Beckham Beckham_human Ronaldo Ronaldo_spain Ronaldo Ronaldo_brazil Beckham Beckham_manch Zidane Zidane_Fran Rooney Rooney_Eng Output shud be (1 Reply)
Discussion started by: cdfd123
1 Replies

5. Shell Programming and Scripting

Sed or Awk for lines between two strings multiple times and keep the last one

Hi, I am trying to get lines between the last occurrences of two patterns. I have files that have several occurrences of “Standard” and “Visual”. I will like to get the lines between “Standard” and “Visual” but I only want to retain only the last one e.g. Standard Some words Some words Some... (4 Replies)
Discussion started by: damanidada
4 Replies

6. Shell Programming and Scripting

Problem with printing the strings

hello all, I am novice to shell scripting and need your help guys.I have a file called myfile.txt and its contents are shown below : <project name="device/samsung/crespo" revision="c932ac3b9f8a53a5c433dc7d3cfa2fb5d45a7eb9"/> <project name="device/samsung/crespo4g"... (7 Replies)
Discussion started by: acdc
7 Replies

7. Programming

Printing same strIng many times

In python how we need to print a same string many times without using loop. I cane across something like * operator for this . How we Can use this in a print statement ? I am using python 3.x Please help me (7 Replies)
Discussion started by: pandeesh
7 Replies

8. Shell Programming and Scripting

Printing Number of Fields with the line number

Hi, How to print the number of fields in each record with the line number? Lets saw I have 3212|shipped|received| 3213|shipped|undelivered| 3214|shipped|received|delivered I tried the code awk -F '|' '{print NF}' This gives me ouput as 3 3 4 (5 Replies)
Discussion started by: machomaddy
5 Replies

9. Shell Programming and Scripting

Count how many times in every file, strings appeared in a directory.

Hello, I have some files and i want to count how many times a string is appeared in each file. Lets say : #cat fileA stringA sdh stringB stringA #cat fileB stringB stringA sdb stringB stringB I need the output to be something like: (2 Replies)
Discussion started by: @dagio
2 Replies

10. Shell Programming and Scripting

Print String N times the number before it

Hey All, I want want to print a string N times the number N before it. Like i have "20 hello". so i want to print hello hello hello . . . . . 20 times.. Please help me.. I am not able o figure out.. how to do the same? (8 Replies)
Discussion started by: jaituteja
8 Replies
sccsfile(4)							   File Formats 						       sccsfile(4)

NAME
sccsfile - format of an SCCS history file DESCRIPTION
An SCCS file is an ASCII file consisting of six logical parts: checksum Character count used for error detection. delta table Log containing version info and statistics about each delta. usernames Login names and/or group IDs of users who may add deltas. flags Definitions of internal keywords. comments Arbitrary descriptive information about the file. body the Actual text lines intermixed with control lines. Each section is described in detail below. Conventions Throughout an SCCS file there are lines which begin with the ASCII SOH (start of heading) character (octal 001). This character is here- after referred to as the control character, and will be represented as `^A'. If a line described below is not depicted as beginning with the control character, it cannot do so and still be within SCCS file format. Entries of the form ddddd represent a five digit string (a number between 00000 and 99999). Checksum The checksum is the first line of an SCCS file. The form of the line is: ^A hddddd The value of the checksum is the sum of all characters, except those contained in the first line. The ^Ah provides a magic number of (octal) 064001. Delta Table The delta table consists of a variable number of entries of the form: ^As inserted/deleted/unchanged ^Ad type sid yr/mo/da hr:mi:se username serial-number predecessor-sn ^Ai include-list ^Ax exclude-list ^Ag ignored-list ^Am mr-number ... ^Ac comments ... ... ^Ae The first line (^As) contains the number of lines inserted/deleted/unchanged respectively. The second line (^Ad) contains the type of the delta (normal: D and removed: R), the SCCS ID of the delta, the date and time of creation of the delta, the user-name corresponding to the real user ID at the time the delta was created, and the serial numbers of the delta and its predecessor, respectively. The ^Ai, ^Ax, and ^Ag lines contain the serial numbers of deltas included, excluded, and ignored, respectively. These lines do not always appear. The ^Am lines (optional) each contain one MR number associated with the delta. The ^Ac lines contain comments associated with the delta. The ^Ae line ends the delta table entry. User Names The list of user-names and/or numerical group IDs of users who may add deltas to the file, separated by NEWLINE characters. The lines con- taining these login names and/or numerical group IDs are surrounded by the bracketing lines ^Au and ^AU. An empty list allows anyone to make a delta. Flags Flags are keywords that are used internally (see sccs-admin(1) for more information on their use). Each flag line takes the form: ^Af flag optional text The following flags are defined in order of appearance: ^Af t type-of-program Defines the replacement for the %T% ID keyword. ^Af v program-name Controls prompting for MR numbers in addition to comments. If the optional text is present, it defines an MR number validity checking program. ^Af i Indicates that the `No id keywords' message is to generate an error that terminates the SCCS command. Otherwise, the message is treated as a warning only. ^Af b Indicates that the -b option may be used with the SCCS get command to create a branch in the delta tree. ^Af m module-name Defines the first choice for the replacement text of the %M% ID keyword. ^Af f floor Defines the "floor" release, that is, the release below which no deltas may be added. ^Af c ceiling Defines the "ceiling" release, that is, the release above which no deltas may be added. ^Af d default-sid The d flag defines the default SID to be used when none is specified on an SCCS get command. ^Af n The n flag enables the SCCS delta command to insert a "null" delta (a delta that applies no changes) in those releases that are skipped when a delta is made in a new release (for example, when delta 5.1 is made after delta 2.7, releases 3 and 4 are skipped). ^Af j Enables the SCCS get command to allow concurrent edits of the same base SID. ^Af l lock-releases Defines a list of releases that are locked against editing. ^Af q user-defined Defines the replacement for the %Q% ID keyword. ^Af e 0|1 The e flag indicates whether a source file is encoded or not. A 1 indicates that the file is encoded. Source files need to be encoded when they contain control characters, or when they do not end with a NEWLINE. The e flag allows files that contain binary data to be checked in. Comments Arbitrary text surrounded by the bracketing lines ^At and ^AT. The comments section typically will contain a description of the file's pur- pose. Body The body consists of text lines and control lines. Text lines do not begin with the control character, control lines do. There are three kinds of control lines: insert, delete, and end, represented by: ^AI ddddd ^AD ddddd ^AE ddddd respectively. The digit string is the serial number corresponding to the delta for the control line. SEE ALSO
sccs-admin(1), sccs-cdc(1), sccs-comb(1), sccs-delta(1), sccs-get(1), sccs-help(1), sccs-prs(1), sccs-prt(1), sccs-rmdel(1), sccs-sact(1), sccs-sccsdiff(1), sccs-unget(1), sccs-val(1), sccs(1), what(1) SunOS 5.10 30 Sep 2002 sccsfile(4)
All times are GMT -4. The time now is 03:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy