Sponsored Content
Top Forums Shell Programming and Scripting Insert newline when grep result is empty Post 302980047 by MadeInGermany on Tuesday 23rd of August 2016 08:29:52 AM
Old 08-23-2016
Hmm, normally an empty line gives more processing problems than no line.
Perhaps you can store in a variable and echo it:
Code:
result=$(
awk -F ";" '{print $19}' /Users/jb/Desktop/ReorderTempTotal.csv  | grep -o "\d.*"
)
echo "$result"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to keep newline characters in command execution result?

I found that when I used a variable to receive the result from a command execution, the newline characters were removed from the variable. For example, I ran $ ret=`ls -l` $ echo $ret Then, I saw: total 40 -rw-r--r-- 1 testtrunk testtrunk 0 Dec 13 11:13 pk -rw-rw-r-- 1 testtrunk... (2 Replies)
Discussion started by: pankai
2 Replies

2. Shell Programming and Scripting

use regexp to insert newline within a line

I have successfully used regexp and sed to insert a newline before or after a line containing a matched pattern /WORD/. However, I want to insert a newline immediately following /WORD/ and not after the -line- containing the pattern matched. I can match a pattern, but it is matched via a wild card... (2 Replies)
Discussion started by: kpeirce
2 Replies

3. Shell Programming and Scripting

Insert two newline after some pattern

Hi, I need to insert two newline characters after matching of a pattern in each line of a file. Eg. If i have a file with contents as follows:- Now, i want output as follows :- i.e., I need to insert two newline characters after the occurance of pattern "</Message>>". Thnx... (1 Reply)
Discussion started by: DTechBuddy
1 Replies

4. Shell Programming and Scripting

How to check a variable for empty and a newline

I have a variable with a new line. I want to check this variable for empty or a new line Can anyone advise (4 Replies)
Discussion started by: Muthuraj K
4 Replies

5. Shell Programming and Scripting

AWK Script Issue insert newline for a regular expression match

Hi , I am having an issue with the Awk script to insert newline for a regular expression match Having a file like this FILE1 #################### RXOER , RXERA , RXERC , RXERD .RXEA(RXBSN), RXERD , REXCD input RXEGT buffer RXETRY ####################### Want to match the RXE... (38 Replies)
Discussion started by: jaita
38 Replies

6. Shell Programming and Scripting

sed insert text without newline

Hi, I use sed to insert text at beginning of a file. But sed inserts a newline after my text that I do not need. For example, I want to insert "foo" at the beginning of my file: > cat myfile This is first line. > sed -i '1i\foo' myfile > cat myfile foo This is first line. ... (5 Replies)
Discussion started by: tdw
5 Replies

7. Solaris

grep result in newline

Hi While trying to do a search on solaris, the grep results seems to be appearing on the same line instead of the new line. Wed Jan 18 14:45:48 weblogic@test:/abcd$ grep qainejb02 * qa_cluster_biz_view_tc_intl_servers_ports_2:qainejb02 7101 qa_cluster_servers_2:qainejb02... (2 Replies)
Discussion started by: ganga.dharan
2 Replies

8. Shell Programming and Scripting

Insert a newline in XML

Hi guys, I got a requirement that ... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

9. UNIX for Dummies Questions & Answers

Insert row into empty file...how?

Greetings: I generate an empty flat file just fine when there's no data returned from my process, as the customer wants one always (using the 1st line of the below script). However, they also want at least the column names in this flat file (row 1, the only row to be in the emply file). I'm... (7 Replies)
Discussion started by: Benrosa
7 Replies

10. Shell Programming and Scripting

Insert a newline after match in files of specific name under some subdirectories?

Hi I'd like to add the newline: \tuser: nobody", or "<TAB>user: nobody to all files named: docker-compose.ymlin subfolders of pwd with names beginning with 10-20. Within these files, I'd like to find the line (there'll only be one) containing: command: celery workerNOTE: As far as... (2 Replies)
Discussion started by: duncanbetts
2 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 04:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy