awk next time replaced by none


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk next time replaced by none
# 1  
Old 08-16-2010
awk next time replaced by none

Hi Everyone,

1.txt
Code:
a
b
c

d
e

f d
g
gg

output:
Code:
abc
de
f dggg

how to use perl or awk, can replace '\n' with '' except the line is empty.
Please advice.

Thanks
[/code]
# 2  
Old 08-16-2010
Code:
awk -vRS="" '{gsub("\n","")}1' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 08-16-2010
Quote:
Originally Posted by bartus11
Code:
awk -vRS="" '{gsub("\n","")}1' file

Learnt, thanks
# 4  
Old 08-16-2010
Another one:
Code:
awk '$1=$1' RS= FS= OFS= file

This User Gave Thanks to Franklin52 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: time intervals based on epoch time

I have a list of epoch times delimited by "-" as follows: 1335078000 - 1335176700 1335340800 - 1335527400 1335771300 - 1335945600 1336201200 - 1336218000 The corresponding dates are: 20120422 1000 - 20120423 1325 20120425 1100 - 20120427 1450 20120430 1035 - 20120502 1100 ... (3 Replies)
Discussion started by: alex2005
3 Replies

2. Programming

Find gaps in time data and replace missing time value and column 2 value by interpolation in awk

Dear all, I am kindly seeking assistance on the following issue. I am working with data that is sampled every 0.05 hours (that is 3 minutes intervals) here is a sample data from the file 5.00000 15.5030 5.05000 15.6680 5.10000 16.0100 5.15000 16.3450 5.20000 16.7120 5.25000... (4 Replies)
Discussion started by: malandisa
4 Replies

3. Shell Programming and Scripting

How to deal with replaced files?

My task is to copy all files from many directories in one. The big problem i encounter is that some files in different directory have the same names. Is they are way to copy the files that have same names in a sub directory ( need to preserve the name of the files unchanged ) I have list with... (6 Replies)
Discussion started by: gogok_bg
6 Replies

4. UNIX for Dummies Questions & Answers

Converting string date time to unix time in AWK

I'd like to convert a date string in the form of sun aug 19 09:03:10 EDT 2012, to unixtime timestamp using awk. I tried This is how each line of the file looks like, different date and time in this format Sun Aug 19 08:33:45 EDT 2012, user1(108.6.217.236) all: test on the 17th ... (2 Replies)
Discussion started by: bkkid
2 Replies

5. Solaris

Veritas not attaching replaced disk

Hi, I`m on SunFire480R with Solaris 10. Disk in rootdg group failed, so it was replaced. However, I cannot make Veritas initalise the replaced disk: # vxdctl enable # vxdisk list c1t0d0s2 Device: c1t0d0s2 devicetag: c1t0d0 type: auto flags: online error private autoconfig... (1 Reply)
Discussion started by: masloff
1 Replies

6. Shell Programming and Scripting

variable value is not getting replaced

Hi, I am trying to generate list of employees from emp table who joined yesterday. emp.sh YEST=$(date --date='1 day ago' +%Y-%m-%d) cat emp.sql | mysql -u <user> -p<pass> -h <host> -P <port> -D <dbname> > emp.csv emp.sql select * from employee where join_date = '$YEST'; I expected... (3 Replies)
Discussion started by: ravi.videla
3 Replies

7. Shell Programming and Scripting

gsub in Awk to capture count of replaced characters

Hi , I am working on a script to replace special characters in ASCII file with '?'. We need to get count of replaced characters from file. I am new to Awk and i read, # The gsub function returns the number of substitutions made. I was trying to replace characters with below... (10 Replies)
Discussion started by: Akshay
10 Replies

8. Shell Programming and Scripting

comma replaced with pipe

Source data: "123","aaa bbb CCC","12000" "134","HHH,bbc","13000" i have a delimited file. i want to replace with the pipe.The sed command is not working for replacing a delimeter. Command : sed s/\,/\|/g filename Output : When i run the command it is replacing the columns value... (7 Replies)
Discussion started by: number10
7 Replies

9. Programming

Can Mutex be replaced with anything?

Hi All, To avoid race condition, instead of using mutex, semaphore, spinlock etc.... Is there any other mechanism by which we can avoid race condition in an multi-threading environment. -Thanks (6 Replies)
Discussion started by: rvan
6 Replies

10. AIX

hdisk0 becomes hdisk2 after replaced

hello, I must've screwed something here.. I just had hdisk0 replaced by IBM.. now it shows up as hdisk2 instead. Before doing that, I've had it split from hdisk1, and reduced from rootvg. Just did a rmdev -dl hdisk2.. ran cfgmgr, but still shows up as hdisk2 instead of hdisk0.. help! (2 Replies)
Discussion started by: kiem
2 Replies
Login or Register to Ask a Question