Sponsored Content
Top Forums Shell Programming and Scripting Number some lines discard others? Post 302753235 by jeppe83 on Tuesday 8th of January 2013 09:33:41 AM
Old 01-08-2013
Number some lines discard others?

Hi,
I'd like to do an operation on text with a format like this

Code:
this line shall be numbered
     this line shall not be numbered
this line shall also be numbered
     this line shall not not be numbered

And I want an output like this
Code:
1 this line shall be numbered
     this line shall not be numbered
2 this line shall also be numbered
     this line shall not not be numbered

nl numbers each line, and I can't seem to find a way for nl to discard lines beginning with spaces/tabs or any other specified set of characteristics.

Any solution is much appreciated. Thank you for reading!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

2. Programming

how to discard instruction from previous signal

hello everyone, I'm having a problem doing signal handling so I post this thread to see if I could get help. I want asynchronous signal handling, that means when I'm processing a signal (signal 1), if the same signal comes (signal 2) that signal (signal 2) shall be processed; and moreover,... (7 Replies)
Discussion started by: nvhoang
7 Replies

3. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

4. Shell Programming and Scripting

count the number of lines that start with the number

I have a file with contents similar to this. abcd 1234 4567 7666 jdjdjd 89289 9382 92 jksdj 9823 298 I want to write a shell script which count the number of lines that start with the number (disregard the lines starting with alphabets) (1 Reply)
Discussion started by: grajp002
1 Replies

5. Shell Programming and Scripting

sed discard chars after last _

Hi, I'd get fields like unix_linux_form_yyyyddmmhhmi.file.txt shell_programming_and_scripting.txt so on... and want them as below unix_linux_form shell_programming_and I could remove everything after a '.' as below echo $field | sed 's/\..*//' but how to remove... (14 Replies)
Discussion started by: dips_ag
14 Replies

6. Shell Programming and Scripting

how to find pattern and discard lines before it?

Hi all, I'd like to search a file for the first occurence of the phrase "PLASTICS THAT EXPIRE" and then discard all the lines that came before it. Output the remainder to a new file. Operating system is hp-ux. I've searched for usual awk and sed one liners but can't find a solution. Thank... (4 Replies)
Discussion started by: Scottie1954
4 Replies

7. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

8. Shell Programming and Scripting

Discard part of a file based on a pattern ---

I have the file: s3_T0(2) Pos "1" "2" s1_T1(2) Pos "1" "2" --- 0 0 1 0 0 1 1 1 --- 1 2 "tau0" 1 2 "h10" I want to patternmatch on --- and get only the third part i.e. 1 2 "tau0" 1 2 "h10" I wanted to start simple but even something like (5 Replies)
Discussion started by: eagle_fly
5 Replies

9. UNIX for Dummies Questions & Answers

Crunch character combination and discard similar content

Hi guys ! I generated the power set of the set S={a,b,c} using crunch: crunch 1 3 abc and get the 39 possible subsets: a b c aa ab ac ba bb bc ca cb cc … (2 Replies)
Discussion started by: beca123456
2 Replies

10. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
Gnome2::Canvas::RichText(3pm)				User Contributed Perl Documentation			     Gnome2::Canvas::RichText(3pm)

NAME
Gnome2::Canvas::RichText - Rich text canvas item HIERARCHY
Glib::Object +----Glib::InitiallyUnowned +----Gtk2::Object +----Gnome2::Canvas::Item +----Gnome2::Canvas::RichText METHODS
textbuffer = $text->get_buffer $text->set_buffer ($buffer) o $buffer (Gtk2::TextBuffer) $text->copy_clipboard $text->cut_clipboard textiter = $text->get_iter_at_location ($x, $y) o $x (integer) o $y (integer) rectangle = $text->get_iter_location ($iter) o $iter (Gtk2::TextIter) $text->paste_clipboard PROPERTIES
'anchor' (Gtk2::AnchorType : default "north-west" : readable / writable) Anchor point for text 'cursor-blink' (boolean : default true : readable / writable) Does the cursor blink in this rich text item? 'cursor-visible' (boolean : default true : readable / writable) Is the cursor visible in this rich text item? 'direction' (Gtk2::DirectionType : default "tab-backward" : readable / writable) Text direction 'editable' (boolean : default true : readable / writable) Is this rich text item editable? 'grow-height' (boolean : default false : readable / writable) Should the text box height grow if the text does not fit? 'height' (double : default 0 : readable / writable) Height for text box 'indent' (integer : default 0 : readable / writable) Number of pixels for indentation 'justification' (Gtk2::Justification : default "left" : readable / writable) Justification mode 'left-margin' (integer : default 0 : readable / writable) Number of pixels in the left margin 'pixels-above-lines' (integer : default 0 : readable / writable) Number of pixels to put above lines 'pixels-below-lines' (integer : default 0 : readable / writable) Number of pixels to put below lines 'pixels-inside-wrap' (integer : default 0 : readable / writable) Number of pixels to put inside the wrap 'right-margin' (integer : default 0 : readable / writable) Number of pixels in the right margin 'text' (string : default undef : readable / writable) Text to display 'visible' (boolean : default true : readable / writable) Is this rich text item visible? 'width' (double : default 0 : readable / writable) Width for text box 'wrap-mode' (Gtk2::WrapMode : default "word" : readable / writable) Wrap mode for multiline text 'x' (double : default 0 : readable / writable) X position 'y' (double : default 0 : readable / writable) Y position SIGNALS
tag-changed (Gnome2::Canvas::RichText, Glib::Object) ENUMS AND FLAGS
enum Gtk2::AnchorType o 'center' / 'GTK_ANCHOR_CENTER' o 'north' / 'GTK_ANCHOR_NORTH' o 'north-west' / 'GTK_ANCHOR_NORTH_WEST' o 'north-east' / 'GTK_ANCHOR_NORTH_EAST' o 'south' / 'GTK_ANCHOR_SOUTH' o 'south-west' / 'GTK_ANCHOR_SOUTH_WEST' o 'south-east' / 'GTK_ANCHOR_SOUTH_EAST' o 'west' / 'GTK_ANCHOR_WEST' o 'east' / 'GTK_ANCHOR_EAST' o 'n' / 'GTK_ANCHOR_N' o 'nw' / 'GTK_ANCHOR_NW' o 'ne' / 'GTK_ANCHOR_NE' o 's' / 'GTK_ANCHOR_S' o 'sw' / 'GTK_ANCHOR_SW' o 'se' / 'GTK_ANCHOR_SE' o 'w' / 'GTK_ANCHOR_W' o 'e' / 'GTK_ANCHOR_E' enum Gtk2::DirectionType o 'tab-forward' / 'GTK_DIR_TAB_FORWARD' o 'tab-backward' / 'GTK_DIR_TAB_BACKWARD' o 'up' / 'GTK_DIR_UP' o 'down' / 'GTK_DIR_DOWN' o 'left' / 'GTK_DIR_LEFT' o 'right' / 'GTK_DIR_RIGHT' enum Gtk2::Justification o 'left' / 'GTK_JUSTIFY_LEFT' o 'right' / 'GTK_JUSTIFY_RIGHT' o 'center' / 'GTK_JUSTIFY_CENTER' o 'fill' / 'GTK_JUSTIFY_FILL' enum Gtk2::WrapMode o 'none' / 'GTK_WRAP_NONE' o 'char' / 'GTK_WRAP_CHAR' o 'word' / 'GTK_WRAP_WORD' o 'word-char' / 'GTK_WRAP_WORD_CHAR' SEE ALSO
Gnome2::Canvas, Glib::Object, Glib::InitiallyUnowned, Gtk2::Object, Gnome2::Canvas::Item COPYRIGHT
Copyright (C) 2003-2004 by the Gtk2-Perl Team. This software is licensed under the LGPL; see Gnome2::Canvas for a full notice. perl v5.14.2 2011-11-16 Gnome2::Canvas::RichText(3pm)
All times are GMT -4. The time now is 04:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy