Sponsored Content
Full Discussion: How to remove empty line.?
Top Forums Shell Programming and Scripting How to remove empty line.? Post 302975741 by ken6503 on Friday 17th of June 2016 03:47:53 PM
Old 06-17-2016
How to remove empty line.?

Hi gurus,

I have a script which works fine.

How to pass string into sql query?


Code:
while read p
do
        [ -z "$para" ] && para="'${p}'" || para="${para},'${p}'"
done < file

Moderator's Comments:
Mod Comment Please use code tags as required by forum rules!


a few days ago, there was issue pop up. in the file, there is empty line at end of the file which causes the list became 'a', 'b', 'c', ''.
I know I can remove the line with sed or other command. but just wondering if it is possible to add condition if p is '' then don't concanated.

thanks in advance.

Last edited by RudiC; 06-18-2016 at 05:28 AM.. Reason: Added code tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove empty directory

Hi, I need to delete an empty directory in a temp directory except "dir5" (keep everything that is not empty). Plese advise. Here is an example of my directory. /dir/temp/ dir1 - delete if this is empty dir2 - delete if this is empty dir3 - delete if this is empty dir4 - delete if this... (7 Replies)
Discussion started by: sirrtuan
7 Replies

2. UNIX for Dummies Questions & Answers

Remove only Empty Directories

I know this one was answered before in forum below - https://www.unix.com/unix-dummies-questions-answers/58210-removing-empty-folders-using-find-command.html But that one is closed & I have a question so here it goes. I want to delete all 2006 files. Now if along with the files, if the... (2 Replies)
Discussion started by: kedar.mehta
2 Replies

3. Shell Programming and Scripting

using vi -c to remove empty lines

Hello: I searched here for "vi -c" but found no hits. How can I use vi -c to remove ALL empty lines, regardless of how many? I tried <code> vi -c ":g/^$/d | wq" filename </code> but I have to run it several times. This is NOT homework. :) Thanks for your time. (3 Replies)
Discussion started by: Habitual
3 Replies

4. 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

5. Shell Programming and Scripting

Remove empty line and the next one

Hi all, I'm trying to remove when this condition is met: an empty and the next one I'm using this command: sed '/^$/N; s/&//' file Which searches for an empty line, N attaches it to the next line, and substituing the combination with nothing.... but it is not working. What I'm missing... (1 Reply)
Discussion started by: meuser
1 Replies

6. UNIX for Dummies Questions & Answers

remove empty field

Hi all ! I'm sure it is a basic question but I didn't find any threads that fit my need. How to remove empty fields with awk? Or in other words, how to shift all the fields after an empty field on the left? input: 1|2||3|4|5||6 wanted: 1|2|3|4|5|6 I tried: awk '{for(i=1; i<=NF;... (7 Replies)
Discussion started by: lucasvs
7 Replies

7. Shell Programming and Scripting

Remove empty records

Hello: Is there a simple way to remove empty records of FASTA format file? A FASTA format consists of two parts: header and sequence (for non-biologist, Wiki for details of course!). The header always start with ">" for the name of the sequence. The header must be in this ONLY single line.... (9 Replies)
Discussion started by: yifangt
9 Replies

8. Shell Programming and Scripting

Remove CR only on empty lines

Dear community, I have two output files that contains some CR # cat first.out 1234567890 598679857648566 9 1234567234 365837465873465 4 2342343243 289374982374894 4 # cat second.out 2342342342 ... (2 Replies)
Discussion started by: Lord Spectre
2 Replies

9. 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

10. UNIX for Dummies Questions & Answers

Using awk to remove duplicate line if field is empty

Hi all, I've got a file that has 12 fields. I've merged 2 files and there will be some duplicates in the following: FILE: 1. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, 100 2. ABC, 12345, TEST1, BILLING, GV, 20/10/2012, C, 8, 100, AA, TT, (EMPTY) 3. CDC, 54321, TEST3,... (4 Replies)
Discussion started by: tugar
4 Replies
XEN(4)							   BSD Kernel Interfaces Manual 						    XEN(4)

NAME
xen -- Xen Hypervisor Guest (DomU) Support SYNOPSIS
To compile para-virtualized (PV) Xen guest support into an i386 kernel, place the following lines in your kernel configuration file: options PAE options XEN nooptions NATIVE To compile hardware-assisted virtualization (HVM) Xen guest support with para-virtualized drivers into an amd64 kernel, place the following lines in your kernel configuration file: options XENHVM device xenpci DESCRIPTION
The Xen Hypervisor allows multiple virtual machines to be run on a single computer system. When first released, Xen required that i386 ker- nels be compiled "para-virtualized" as the x86 instruction set was not fully virtualizable. Primarily, para-virtualization modifies the vir- tual memory system to use hypervisor calls (hypercalls) rather than direct hardware instructions to modify the TLB, although para-virtualized device drivers were also required to access resources such as virtual network interfaces and disk devices. With later instruction set extensions from AMD and Intel to support fully virtualizable instructions, unmodified virtual memory systems can also be supported; this is referred to as hardware-assisted virtualization (HVM). HVM configurations may either rely on transparently emu- lated hardware peripherals, or para-virtualized drivers, which are aware of virtualization, and hence able to optimize certain behaviors to improve performance or semantics. FreeBSD supports a fully para-virtualized (PV) kernel on the i386 architecture using options XEN and nooptions NATIVE; currently, this requires use of a PAE kernel, enabled via options PAE. FreeBSD supports hardware-assisted virtualization (HVM) on both the i386 and amd64 kernels; however, PV device drivers with an HVM kernel are only supported on the amd64 architecture, and require options XENHVM and device xenpci. Para-virtualized device drivers are required in order to support certain functionality, such as processing management requests, returning idle physical memory pages to the hypervisor, etc. Xen DomU device drivers Xen para-virtualized drivers are automatically added to the kernel if a PV kernel is compiled using options XEN; for HVM environments, options XENHVM and device xenpci are required. The follow drivers are supported: balloon Allow physical memory pages to be returned to the hypervisor as a result of manual tuning or automatic policy. blkback Exports local block devices or files to other Xen domains where they can then be imported via blkfront. blkfront Import block devices from other Xen domains as local block devices, to be used for file systems, swap, etc. console Export the low-level system console via the Xen console service. control Process management operations from Domain 0, including power off, reboot, suspend, crash, and halt requests. evtchn Expose Xen events via the /dev/xen/evtchn special device. netback Export local network interfaces to other Xen domains where they can be imported via netfront. netfront Import network interfaces from other Xen domains as local network interfaces, which may be used for IPv4, IPv6, etc. pcifront Allow physical PCI devices to be passed through into a PV domain. xenpci Represents the Xen PCI device, an emulated PCI device that is exposed to HVM domains. This device allows detection of the Xen hypervisor, and provides interrupt and shared memory services required to interact with the hypervisor. Performance considerations In general, PV drivers will perform better than emulated hardware, and are the recommended configuration for HVM installations. Using a hypervisor introduces a second layer of scheduling that may limit the effectiveness of certain FreeBSD scheduling optimisations. Among these is adaptive locking, which is no longer able to determine whether a thread holding a lock is in execution. It is recommended that adaptive locking be disabled when using Xen: options NO_ADAPTIVE_MUTEXES options NO_ADAPTIVE_RWLOCKS options NO_ADAPTIVE_SX SEE ALSO
pae(4) HISTORY
Support for xen first appeared in FreeBSD 8.1. AUTHORS
FreeBSD support for Xen was first added by Kip Macy <kmacy@FreeBSD.org> and Doug Rabson <dfr@FreeBSD.org>. Further refinements were made by Justin Gibbs <gibbs@FreeBSD.org>, Adrian Chadd <adrian@FreeBSD.org>, and Colin Percival <cperciva@FreeBSD.org>. This manual page was written by Robert Watson <rwatson@FreeBSD.org>. BUGS
FreeBSD is only able to run as a Xen guest (DomU) and not as a Xen host (Dom0). A fully para-virtualized (PV) kernel is only supported on i386, and not amd64. Para-virtualized drivers under hardware-assisted virtualization (HVM) kernel are only supported on amd64, not i386. As of this release, Xen PV DomU support is not heavily tested; instability has been reported during VM migration of PV kernels. Certain PV driver features, such as the balloon driver, are under-exercised. BSD
December 17, 2010 BSD
All times are GMT -4. The time now is 05:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy