awk prints unwanted new lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk prints unwanted new lines
# 8  
Old 11-12-2014
Hello LinuxRacr,

For simple printing following may help (As per post#1).
Code:
 awk 'END{print "SERVER= " $1 OFS "APPID= "$3 OFS "OS= "$6}' Input_file

For getting values into variables we can use following.
Code:
SERVER=`awk 'END{print $1}' Input_file`
APPID=`awk 'END{print $3}' Input_file`
OS=`awk 'END{print $6}' Input_file`

After that you try to write the script and do the further more operations as you have shown us to create directory etc as per your requirements.
Hope this helps.


Thanks,
R. Singh
# 9  
Old 11-12-2014
Great Scott! I believe my issue is solved. IFS did the trick.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: BEGIN: prints nothing

My code fails to do anything if I've BEGIN block in it: Run the awk script as: awk -f ~/bin/sum_dupli_gene.awk make_gene_probe.txt #!/usr/bin/awk -f BEGIN { print ARGV #--loads of stuff } END{ #more stuff } (14 Replies)
Discussion started by: genome
14 Replies

2. Shell Programming and Scripting

awk prints only last line

data.txt: NEWTEXTS="frq=63,std=-0.00533584,time=Mar-21-(09:15:03)-2016,epoch=1458576903,avg=64.2059,212.698 frq=197,std=0.587585,time=Mar-21-(09:16:02)-2016,epoch=1458576962,avg=64.2059,483.756 frq=178,std=0.503514,time=Mar-21-(09:46:02)-2016,epoch=1458578762,avg=64.2059,500... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Shell Programming and Scripting

get rid of unwanted lines

Hi , My output contains the below contents When i execute df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' i get output as below tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/WebArch.vbs 1.7T 1.3T 452G 74% /vob/WebArch... (6 Replies)
Discussion started by: ptappeta
6 Replies

4. Shell Programming and Scripting

grep out unwanted lines

Hi, I got a log file and I want to grep out a list of unwanted line which are IP's. Basiclly I want everything ecxept the ip's from my list. If I do a while read line do grep -v $ip_from_my_list logfile done <ip_list it just grep's one IP at a time and repeats. :( Thanks for... (3 Replies)
Discussion started by: stinkefisch
3 Replies

5. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

6. Shell Programming and Scripting

awk system() prints extra 0 -- why?

Here's the command I'm running: # echo "hi" | awk '{etime = system("hostname") ; close("hostname") ; print etime""}' And here's the ouput: server.domain.tld 0 Why in the world is that second line, the one that's just "0", there? Many thanks in advance. (2 Replies)
Discussion started by: treesloth
2 Replies

7. Shell Programming and Scripting

Unwanted field separation in awk

Hi everyone, My problem is strange, I cannot think of why this is happening. I have a set of data that looks like this: Although it does not look it, the fields are tab delimited. I have made sure of this, and awk does recognize them as such. However, it divides what I would expect... (2 Replies)
Discussion started by: ccox85
2 Replies

8. UNIX for Advanced & Expert Users

How to Remove the unwanted Blank Lines

I have a file with the below data, i would like to remove the end blank lines with no data. I used the below commands but could not able to succeed, could you please shed some light. Commands Used: sed '/^$/d' input.txt > output.txt grep -v '^$' input.txt > output.txt input.txt file... (5 Replies)
Discussion started by: Ariean
5 Replies

9. Shell Programming and Scripting

awk / grep / Prints all columns except the first one

I have the a file with the following data. File Content. 1249 snf06.3.0 sw version 1.1 code MD5 192F MD4 MD3 1248 sns06.3.0 sw version 1.1 code MD5 192F MD12 1250 sns06.3.0 sw version 1.1 code MD5 192F0\ MD8 1241 sns06.3.0 sw code MD5 19 1243 sn06.3.0 sw version 1.1 code MD5 19 12... (17 Replies)
Discussion started by: knijjar
17 Replies

10. Shell Programming and Scripting

Filter unwanted lines

Hi All, I have the below input and i only want to filter out some un-wanted info from here. Expected output is below. Can somebody help ? The catch is that i want to grep those lines with term "k=" and lines with term "**" as the 1st column and "07" as the last column. And the number of... (15 Replies)
Discussion started by: Raynon
15 Replies
Login or Register to Ask a Question