Sponsored Content
Top Forums Shell Programming and Scripting replace only 1st word of a line if it comes in the subsequent lines at same postion. Post 302137414 by geeko on Tuesday 25th of September 2007 01:24:28 AM
Old 09-25-2007
replace only 1st word of a line if it comes in the subsequent lines at same postion.

I have a file like this..

Maharastra Mumbai worli
Maharastra Mumbai navy
maharatra Pune
Maharastra Nagpur
Karnataka Bangalore
Karnataka Mysore
Karnataka Mangalore
Punjab Amritsar
punjab Jalandar


my expected outcome should be like this

Maharastra Mumbai worli
---------- Mumbai Navy
---------- pune
---------- Nagpur
Karnataka Bangalore
--------- mysore
--------- Mangalore
Punjab Amritsar
--------- Jalandar

i am not able to find any similar posts,please reply

thanks in advance,
regards,
Geeko
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to replace the first word of a line if it occurs again in the next line(shell)

Hi folks, have a look into the attachment, i am not familiar with unix, can you please help me in this regard. thanks in advance, :) regards, Geeko (4 Replies)
Discussion started by: geeko
4 Replies

2. Shell Programming and Scripting

How to search for keywords in subsequent lines

Hi all, I am looking for a coomand to search for the keywords in susequenct lines. Keyword1 in a line and Keyword2 in the very next line. Once i found the combination ineed to print the lines with patterns and the line above and one below. I am giving an example here: Keywords are :ERROR and... (12 Replies)
Discussion started by: rdhanek
12 Replies

3. Shell Programming and Scripting

search for keyword in subsequent lines and delete the second line

I have my data something like this I need to search for the keyword yyyy in the susequent lines and if it is present, delete the second line with keyword. In other words, if a keywords is found in two subsequent lines delete the second line. input data: aaaa bbbbb cccc dddd xxxx... (4 Replies)
Discussion started by: rdhanek
4 Replies

4. Shell Programming and Scripting

Grep and fetch subsequent lines also

Hi, I need to grep a pattern and fetch subsequent lines till end of the data-set. E.g., i have a file like: AA 1111 23 34 BB 45 56 78 CC 22 44 AA 2222 78 34 56 BB 22 56 67 68 23 CC 56 78 DD 33 55 77 AA 3333 46 BB 58 79 In above file i have 3-data sets where each set starts with... (6 Replies)
Discussion started by: prvnrk
6 Replies

5. Shell Programming and Scripting

awk - use fields from subsequent lines

I've run into a problem getting exactly what I want out of awk - some folks may recognize this as an output from Amazon's ec2-describe-instances: Given the following: INSTANCE i-4960f321 BLOCKDEVICE Line2Var2 TAG instance i-4960f321 Name web1 TAG instance i-4960f321... (2 Replies)
Discussion started by: colinjohnson
2 Replies

6. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

7. UNIX for Advanced & Expert Users

Need command for grepping pattern lines with subsequent lines

Hi, I have a requirement like, I have a list of pattens in a file say pattern.txt, PHC111 PHC113 and in another file called master.lst i have entries like, PHC111 a b PHC112 a PHC113 b c PHC114 d e (5 Replies)
Discussion started by: rbalaj16
5 Replies

8. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

9. UNIX for Beginners Questions & Answers

Replace only First Word in Line

I have query to replace the first word in line using below code but its replace the middle word too sed -i 's/load /# LOAD/' /tmp/check.sql Query 1 : UPDATE accheadcon_data_last_upload SET last_upload_date = '2017-07-23' Replace to UPDATE accheadcon_data_last_up# LOAD SET... (1 Reply)
Discussion started by: kaushik02018
1 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
ikiwiki-calendar(1)					      General Commands Manual					       ikiwiki-calendar(1)

NAME
ikiwiki-calendar - create calendar archive pages SYNOPSIS
ikiwiki-calendar [-f] your.setup [pagespec] [startyear [endyear]] DESCRIPTION
ikiwiki-calendar creates pages that use the ikiwiki/directive/calendar directive, allowing the archives to be browsed one month at a time, with calendar-based navigation. You must specify the setup file for your wiki. The pages will be created inside its srcdir, beneath the archivebase directory used by the calendar plugin (default "archives"). To control which pages are included on the calendars, a ikiwiki/PageSpec can be specified. The default is all pages, or the pages specified by the comments_pagespec setting in the config file. A pagespec can also be specified on the command line. To limit it to only posts in a blog, use something like "posts/* and !*/Discussion". It defaults to creating calendar pages for the current year. If you specify a year, it will create pages for that year. Specify a second year to create pages for a span of years. Existing pages will not be overwritten by this command by default. Use the -f switch to force it to overwrite any existing pages. CRONTAB
While this command only needs to be run once a year to update the archive pages for each new year, you are recommended to set up a cron job to run it daily, at midnight. Then it will also update the calendars to highlight the current day. An example crontab: 0 0 * * * ikiwiki-calendar ~/ikiwiki.setup 'posts/* and !*/Discussion' TEMPLATES
This command uses two templates to generate the pages, calendarmonth.tmpl and calendaryear.tmpl. AUTHOR
Joey Hess <joey@ikiwiki.info> ikiwiki-calendar(1)
All times are GMT -4. The time now is 01:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy