Sponsored Content
Top Forums Shell Programming and Scripting Putting new line after certain number of character Post 302299901 by cfajohnson on Sunday 22nd of March 2009 03:51:26 AM
Old 03-22-2009

Code:
awk 'BEGIN { len = 80 }
   length <= 80 { print; next }
   {
     print substr($0,1,len)
     $0 = substr( $0, len + 1)
     while ( length >= len - 4 ) {
        printf "    %s\n", substr($0,1,len - 4)
        $0 = substr( $0, len - 3)
      }
     if ( length ) printf "    %s\n", $0
   }
' "$FILE"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Putting a character between two other characters?

I need to separate Pascal style identifiers (TheyLookLikeThis) into words separated by an underscore (_). I've tried sed 's//&_&/' but this won't work (obviously). I'd love some help. (4 Replies)
Discussion started by: Ilja
4 Replies

2. UNIX for Dummies Questions & Answers

putting grep -c results number in a variable

I want to display "no results found" if a grep search of a name that the user inputs is not found anywhere in a certain file, Right now I have this, but doesn't seem to work. Im not sure what to change. read name results=grep -c $name file if ; then echo "No results found." exit... (1 Reply)
Discussion started by: busdude
1 Replies

3. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

4. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

5. Shell Programming and Scripting

new line after specific number character

Hi All, I have input file like this: input1: ( 1083479)=T 158V 1798, T 391V 1896,T 1138V 2273,T 1547V 2477,T 2249V 2917,T 3278V 3234,T 4152V 3495,T 5500V 3631, ( 1083501)=T 181V 1851, T 459V 1954,T 810V 2141,T 1188V 2372,T 1638V 2696,T 2731V 3124,T 4799V 3640,... (5 Replies)
Discussion started by: attila
5 Replies

6. Shell Programming and Scripting

Need help putting output on one line

Good afternoon, I have been searching the web, and these forums for help. I will try my best to explain the issue, and what my desired results are. I am doing queries in MYSQL, and need the output to be sent to a file. That file needs to have things with the same ID on the same line. To... (14 Replies)
Discussion started by: brianjb
14 Replies

7. Shell Programming and Scripting

Help awk/sed: putting a space after numbers:to separate number and characters.

Hi Experts, How to sepearate the list digit with letters : with a space from where the letters begins, or other words from where the digits ended. file 52087mo(enbatl) 52049mo(enbatl) 52085mo(enbatl) 25051mo(enbatl) The output should be looks like: 52087 mo(enbatl) 52049... (10 Replies)
Discussion started by: rveri
10 Replies

8. Shell Programming and Scripting

How to print a particular character n number of times in a line??

hi, Is it possible to print a particular character n number of times in a line? for example. i am print the following line using echo command.. echo "files successfully moved" i want to count the number of characters that are been displayed. i am doin it using echo "files... (8 Replies)
Discussion started by: Little
8 Replies

9. Shell Programming and Scripting

How to accept command line argument as character or text if number is entered?

Hello Does the unix korn shell provide a function to convert number entered in command line argument to text or Character so that in next step i will convert Chr to Hex (6 Replies)
Discussion started by: aadityapatel198
6 Replies

10. Shell Programming and Scripting

Identifying a sentence and putting it on a new line

I am revisiting the problem of sentence splitting. I have a Perl Script which splits a para into sentences, but acronyms and short forms create an issue #!/usr/bin/perl use feature qw/say/; use strict; use warnings; my $s; my @arr; while(<>) { chomp $_; $s .= $_ . " "; } @arr... (2 Replies)
Discussion started by: gimley
2 Replies
case(3) 						     Library Functions Manual							   case(3)

NAME
case - convert ASCII uppercase bytes to lowercase SYNTAX
#include <case.h> void case_lowers(s); void case_lowerb(s,len); int case_diffs(s,t); int case_equals(s,t); int case_starts(s,t); int case_diffb(s,len,t); int case_startb(s,len,t); char *s; char *t; unsigned int len; DESCRIPTION
case_lowers converts each uppercase byte in the string s to lowercase. s must be 0-terminated. case_lowerb converts each uppercase byte in the buffer s, of length len, to lowercase. case_diffs lexicographically compares lowercase versions of the strings s and t. It returns something positive, negative, or zero when the first is larger than, smaller than, or equal to the second. s and t must be 0-terminated. case_equals means !case_diffs. case_starts returns 1 if a lowercase version of s starts with a lowercase version of t. s and t must be 0-terminated. case_diffb lexicographically compares lowercase versions of the buffers s and t, each of length len. It returns something positive, nega- tive, or zero when the first is larger than, smaller than, or equal to the second. case_startb returns 1 if a lowercase version of the buffer s, of length len, starts with a lowercase version of the string t. t must be 0-terminated. The case routines are ASCII-specific. They are suitable for programs that handle case-independent networking protocols. All comparisons are performed on unsigned bytes. SEE ALSO
byte_diff(3), byte_equal(3), str_diff(3), str_equal(3), str_start(3) case(3)
All times are GMT -4. The time now is 08:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy