Newbie help with New Line & Blank Line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Newbie help with New Line & Blank Line
# 1  
Old 01-22-2009
Newbie help with New Line & Blank Line

I have this in my script:

usercount=`ldapsearch -L -b"ou=people,ou=$ou,dc=paisleyhosting,dc=com" -h"$server" -p"1391" cn=* nothing | grep -c dn`

admincount=`ldapsearch -b"ou=groups,ou=$ou,dc=paisleyhosting,dc=com" -h"$server" -p"1391" cn=USERADMIN* uniquemember | grep uniquemember | sort -u | grep -c unique`

adminusers=`ldapsearch -b"ou=groups,ou=$ou,dc=paisleyhosting,dc=com" -h"$server" -p"1391" "(&(objectclass=groupofuniquenames)(cn=useradministrator))" uniquemember | grep uniquemember | cut -d "," -f 1 | cut -d "=" -f 3`


I want to insert a New Line after "admincount" and a Blank Line after "adminsuers" ...

Can you help?
# 2  
Old 01-22-2009
Why don't you use vi or another editor if you want to insert one line in one script?

Regards
# 3  
Old 01-22-2009
Because my script produces hundred of lines and it results in many line breaks and blank lines. I want the blank lines and the new lines included in the output.

Last edited by kthatch; 01-22-2009 at 03:39 PM.. Reason: typo
# 4  
Old 01-22-2009
My output is like this:

301,1,1,301jjones
302,1,1,302jjones
303,200,4,303jdeer
303mjohnson
303jjones
303kwoods
304,30,1,304jjones
305,1,1,305jjones
306,37,3,306jjones
306swalker
306bblanks
........ etc ......

I want output to be:

301,1,1,
301jjones

302,1,1,
302jjones

303,200,4,
303jdeer
303mjohnson
303jjones
303kwoods

304,30,1,
304jjones

305,1,1,
305jjones

306,37,3,
306jjones
306swalker
306bblanks
........ etc ......
# 5  
Old 01-23-2009
Can someone please help with New Lines and Blank Lines?
# 6  
Old 01-23-2009
something along these lines

nawk -f kt.awk myInputFile

kt.awk:
Code:
BEGIN {
  FS=OFS=","
}
FNR==1 {curr=$1}
$1 != curr && NF>1 { curr=$1; printf "\n"}
{
  if (NF>3)
     print $1,$2,$3 ORS $4
  else
     print
}

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

In a file, replace blank line by the last line not blank above

Dear All, In a CSV file, say that a given column has been extracted. In that column, information is missing (i.e. blank lines appear). I would like to replace the blank lines by the last valid line (not blank) previously read. For example, consider the extract below: 123 234 543 111... (7 Replies)
Discussion started by: bagvian
7 Replies

2. Shell Programming and Scripting

Combine multiline to one line till a blank line

Hello, I have a file as :- ABC DEF GHI JKL <BlankLine> MNO PQR STU VWX <BlankLine> YZA I need it as below:- ABCDEFGHIJKL; MNOPQRSTUVWX; (3 Replies)
Discussion started by: jassi10781
3 Replies

3. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

4. Shell Programming and Scripting

String search and print next all lines in one line until blank line

Dear all I want to search special string in file and then print next all line in one line until blank lines come. Help me plz for same. My input file and desire op file is as under. i/p file: A1/EXT "BSCABD1_21233G1" 757 130823 1157 RADIO X-CEIVER ADMINISTRATION BTS EXTERNAL FAULT ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

5. Shell Programming and Scripting

Print lines between a regExp & a blank line

Hi, I have a file, say files_list, as below (o/p of ls -R cmd) $ cat files_list /remote/dir/path/to/file: sub-dir1 sub-dir2 sub-dir3 ... /remote/dir/path/to/file/sub-dir1: remote_file1.csv.tgz <blank line 1> /remote/dir/path/to/file/sub-dir2: remote_file2.csv.tgz <blank... (3 Replies)
Discussion started by: dips_ag
3 Replies

6. Shell Programming and Scripting

Fill the empty line by adding line before blank line

FIle A "A" 2 aa 34 3 ac 5 cd "B" 3 hu 67 4 fg 5 gy output shud be A"" 2 aa 34 "A" 3 ac 34 "A" 5 cd 34 "B" 3 hu 67 "B" 4 fg 67 "B" 5 gy 67 (6 Replies)
Discussion started by: cdfd123
6 Replies

7. Shell Programming and Scripting

Replace two blank line with a single blank line

Hi Guys, I have a file in which each set of records are separated by two blank line. I want to replace it with a single blank line. Can you guys help me out? Regards, Magesh (9 Replies)
Discussion started by: mac4rfree
9 Replies

8. UNIX for Dummies Questions & Answers

Question: Help need to remove blank line & sed: Couldn't re-allocate memory error.

I've shell script where i used the below command to take the line which contains patterns. sed -n "/$year 05:/,/$year 17:/p" trace.log | grep -f patterns.txt > output.log This was working fine for long time, but now a days this script is not working with and throwing error like sed:... (8 Replies)
Discussion started by: senthil.ak
8 Replies

9. Shell Programming and Scripting

sed: delete regex line and next line if blank

Hi, I want to write a sed script which from batiato: batiato/giubbe: pip_b.2.txt pip_b.3.txt pip_b.3mmm.txt bennato: bennato/peterpan: 123.txt consoli: pip_a.12.txt daniele: (2 Replies)
Discussion started by: one71
2 Replies

10. UNIX for Dummies Questions & Answers

Newbie ? Need Help with If/Then & Line Breaks...

I hope this makes sense, but I need help with what is indicated with %%, below : A.) ####List active servers and send to file#### # ps -ef | grep jboss | grep sh | awk '{if ($14) {print $12;}else {print $11}}' | sort > /export/home/kthatch/script_results client302 client306 client309... (1 Reply)
Discussion started by: kthatch
1 Replies
Login or Register to Ask a Question