Sponsored Content
Full Discussion: positioning words in a line
Top Forums UNIX for Dummies Questions & Answers positioning words in a line Post 302699239 by A-V on Tuesday 11th of September 2012 09:55:16 AM
Old 09-11-2012
I have a whole folder which they have pattens of 5 words of Y= [Dean James John Mark Bob], so I have 25 files with pattern of $Y-$Y
now in each one of these $Y-$Y i have lines that again which will again have $Y
now I need to get the pattern as $Y-$Y-$Y with will have only two columns
$1 = position of the words $Y
$2 = number of the words in each line

As I am new, I was dividing each line to a file and then break each word to new file and then get NR --- i know its funny but im learning Smilie
Code:
FILES="F1/*"
for X in $FILES
do
    name=$(basename $X) 
    awk -v NM="$name" '$0 != ""{ print > "F2/"NM"-"NR".txt" }' $X 
done
#word per line separator 
FILES="F2/*"
for X in $FILES
do
	name=$(basename $X) 
	cat $X | tr ‘ ‘ ‘\n’ >F3/${name}
done
#get the position and count the number of lines per file
FILES="F3/*"
for X in $FILES
do
	name=$(basename $X) 
awk  '/^Dean$|^James$|^John$|^Mark$|^Bob$/  {print $1,  NR }'  $X > F4/${name}
awk  'END{print NR-1}'  $X > F5/${name}
done

this is a mess and those not really do what I need for the naming which is adding the third parameter as well and has many separate files which need to be added up later...
I am looking for more appropriate way of doing it

@Pamu: I used used as its the same problem Smilie Smilie

Last edited by A-V; 09-11-2012 at 11:42 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

seperating the words from a line??

The line is like this +abc+def+mgh+ddsdsd+sa i.e. words seperated by +. There is a plus in the beginning. i want to conver this line to abc, def, mgh, ddsdsd, sa please provide the logic in the form of a shell script Thanks in advance (3 Replies)
Discussion started by: skyineyes
3 Replies

2. Shell Programming and Scripting

how to get line number of different words if exists in same line

I have some txt files. I have to create another text file which contains the portion starting from the format "Date Sex Address" to the end of the file. While using grep -n on Date it also gives me the previous line containg Date. and also Date may be DATE in some files. My file is like this... (10 Replies)
Discussion started by: Amiya Rath
10 Replies

3. Shell Programming and Scripting

count no of words in a line

hi i have a line "abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc,def ,ghi,abc,def,ghi,abc" I want to print the no of words, words separated by comma please help (3 Replies)
Discussion started by: Satyak
3 Replies

4. Shell Programming and Scripting

sort words in a line

Hi Im looking for a way, hopefully a one-liner to sort words in a line e.g "these are the words in a line" to "a are in line the these words" Thanks! (15 Replies)
Discussion started by: rebelbuttmunch
15 Replies

5. Shell Programming and Scripting

How to print the words in the same line with space or to the predefined line?

HI, cat test abc echo "def" >> test output is cat test abc def the needed output is cat test abc def and so on (5 Replies)
Discussion started by: jobycxa
5 Replies

6. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

7. Shell Programming and Scripting

get few words from same line

Hello all i tried awk , cut but i think something missing i have this line @@XYMONDCHK-V1|.acklist.|developer_instead|rendy_google_yagom|1323977582|1323979382|1323979382|1|admin|test case i want cut some words to be in new line like this... (6 Replies)
Discussion started by: mogabr
6 Replies

8. Shell Programming and Scripting

Search words in multiple file line by line

Hi All I have to search servers name say like 1000+ "unique names" line by line in child.txt files in another file that is a master file where all server present say "master.txt",if child.txt's server name matches with master files then it print yes else no with server name. (4 Replies)
Discussion started by: netdbaind
4 Replies

9. Shell Programming and Scripting

Separating words in a line

Hi I have the following file # cat red it.d-state = 50988 41498 45 0 0 0 it.age_buffer= 1500 it.dir = 1 I need to grep lines that are present after "=" But when I do so, few lines has more than one value and some has one How to parse the line I have used the follwing... (6 Replies)
Discussion started by: Priya Amaresh
6 Replies

10. Shell Programming and Scripting

Replace particular words in file based on if finds another words in that line

Hi All, I need one help to replace particular words in file based on if finds another words in that file . i.e. my self is peter@king. i am staying at north sydney. we all are peter@king. How to replace peter to sham if it finds @king in any line of that file. Please help me... (8 Replies)
Discussion started by: Rajib Podder
8 Replies
PAPS(1) 						      General Commands Manual							   PAPS(1)

NAME
paps - UTF-8 to PostScript converter using Pango SYNOPSIS
paps [options] files... DESCRIPTION
paps reads a UTF-8 encoded file and generates a PostScript language rendering of the file. The rendering is done by creating outline curves through the pango ft2 backend. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --landscape Landscape output. Default is portrait. --columns=cl Number of columns output. Default is 1. --font=desc Set the font description. Default is Monospace 12. --rtl Do rtl layout. --paper ps Choose paper size. Known paper sizes are legal, letter, a4. Default is A4. --bottom-margin=bm Set bottom margin in postscript points (1/72 inch). Default is 36. --top-margin=tm Set top margin. Default is 36. --left-margin=lm Set left margin. Default is 36. --right-margin=rm Set right margin. Default is 36. --help Show summary of options. --header Draw page header for each page. --markup Interpret the text as pango markup. --encoding=ENCODING Assume the documentation encoding is ENCODING. --lpi Set the lines per inch. This determines the line spacing. --cpi Set the characters per inch. This is an alternative method of specifying the font size. --stretch-chars Indicates that characters should be stretched in the y-direction to fill up their vertical space. This is similar to the texttops behaviour. AUTHOR
paps was written by Dov Grobgeld <dov.grobgeld@gmail.com>. This manual page was written by Lior Kaplan <kaplan@debian.org>, for the Debian project (but may be used by others). April 17, 2006 PAPS(1)
All times are GMT -4. The time now is 11:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy