Sponsored Content
Top Forums Shell Programming and Scripting Putting a separator in file using awk/bash Post 302844018 by mjf on Friday 16th of August 2013 06:13:34 AM
Old 08-16-2013
Here's another way using awk:

Code:
 awk -F- '{if (NR==1) {first=$1}} {if (first==$1) print $0; else {print "#"; print $0; first=$1}}' file.txt

This User Gave Thanks to mjf For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk spliting using separator

Hi I have a file which looks like this #HEllo #How.... #version 1.0.1 #Author aaaaa ab.-.1.-.90.-.80.-..-.OK cd.-.8.-.91.-.800.-.xy.-..-. the separator is .-. (dot hyphen dot) I want to display this as columns like ab cd 1 8 90 91 (1 Reply)
Discussion started by: PrasannaKS
1 Replies

2. Shell Programming and Scripting

Field separator in awk

Hi I need to check if field separator I am using in awk statement is " : ", for example: TIME=12:59 HOUR=`echo "$TIME" | awk '{FS=":"; print $1}'` MINUTES=`echo "$TIME" | awk '{FS=":"; print $2}'` Is there a way to check within the above awk statement ? Thanks for help -A (2 Replies)
Discussion started by: aoussenko
2 Replies

3. Shell Programming and Scripting

Putting values into order in a field using awk

Hi, I am using UBUNTU 12.04. I have a dataset as follows: Column#1 Column#2 Column#3 .... Column#50 1 154878 1 145145 2 189565 2 454121 ... (5 Replies)
Discussion started by: Homa
5 Replies

4. Shell Programming and Scripting

awk field separator

I need to set awk field separator to ";", but I need to avoid ";EXT". so that echo a;b;c;EXTd;e;f | awk -F";" '{print $3}' would give "c;EXTd" (2 Replies)
Discussion started by: locoroco
2 Replies

5. Programming

Putting bash script in C program

suppose i have a bash script: #!/bin/bash echo "hello" echo "how are you" echo "today" how can i put the entire script above into a basic c program? i do not want to translate the bash code to a c code. i want C to run the bash code. is this possible? i found this on the... (15 Replies)
Discussion started by: SkySmart
15 Replies

6. Shell Programming and Scripting

awk field separator help -

Hi Experts , file : - How to construct the awk filed separator so that $1, $2 $3 , can be assigned to the each "" range. I am trying : awk -F"]" '{print $1}' but it is printing the entire file. Not first field. The desired output needed for first field... (9 Replies)
Discussion started by: rveri
9 Replies

7. Shell Programming and Scripting

Field Separator in printf (awk)

I can not figure out how to set the Output filed separator in awk when using printf. Example: cat file some data here_is_more information Requested output some------------data her_is_more-----information Here are some that does not work: awk '{printf "%-15s %s\n",$1,$2}' OFS="-" file... (9 Replies)
Discussion started by: Jotne
9 Replies

8. Shell Programming and Scripting

How to use variable as separator in awk?

can some give me a example ? eg: a=usb I want to use variable "a" as separator (2 Replies)
Discussion started by: yanglei_fage
2 Replies

9. Shell Programming and Scripting

Use string as Record separator in awk

Hello to all, Please some help on this. I have the file in format as below. How can I set the record separator as the string below in red "No. Time Source Destination Protocol Length Info" I've tried code below but it doesn't seem to... (6 Replies)
Discussion started by: cgkmal
6 Replies

10. Shell Programming and Scripting

Awk, with separator |

Friends have the following code that is correct. BEGIN { num_reg = 0 suma_iva=0 } { num_reg++ suma_iva=suma_iva+int(substr($0, 103,9)) } END{ printf ("%011d",suma_iva) } I have the following problem, I have to do just that but this time... (4 Replies)
Discussion started by: tricampeon81
4 Replies
XmScrollVisible(library call)											     XmScrollVisible(library call)

NAME
XmScrollVisible -- A ScrolledWindow function that makes an invisible descendant of a ScrolledWindow work area visible SYNOPSIS
#include <Xm/ScrolledW.h> void XmScrollVisible( Widget scrollw_widget, Widget widget, Dimension left_right_margin, Dimension top_bottom_margin); DESCRIPTION
XmScrollVisible makes an obscured or partially obscured widget or gadget descendant of a ScrolledWindow work area visible. The function re- positions the work area and sets the specified margins between the widget and the nearest viewport boundary. The widget's location relative to the viewport determines whether one or both of the margins must be adjusted. This function requires that the XmNscrollingPolicy of the ScrolledWindow widget be set to XmAUTOMATIC. scrollw_widget Specifies the ID of the ScrolledWindow widget whose work area window contains an obscured descendant. widget Specifies the ID of the widget to be made visible. left_right_margin Specifies the margin to establish between the left or right edge of the widget and the associated edge of the viewport. This margin is established only if the widget must be moved horizontally to make it visible. top_bottom_margin Specifies the margin to establish between the top or bottom edge of the widget and the associated edge of the viewport. This margin is established only if the widget must be moved vertically to make it visible. For a complete definition of ScrolledWindow and its associated resources, see XmScrolledWindow(3) RELATED
XmScrolledWindow(3). XmScrollVisible(library call)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy