Sponsored Content
Operating Systems Linux Issue in inserting null string in array Post 302988561 by millan on Wednesday 28th of December 2016 07:55:38 AM
Old 12-28-2016
Issue in inserting null string in array

I am getting some values from a file and putting them in an array..but the null strings are not getting passed to the array. So during printing the elements ,the null string is not showing in the output. during array size calculation it is also excluding null.Please let me know how to do it.
Code:
[root]# cat testlog
              saveset name: ;
              saveset name: /;
              saveset name: /  ;
[root]#

 [root]# awk '/saveset name:/ {for(i=3;i<=NF;i++) {gsub("\"",""); printf( "%s ", $i )}; printf( "\n"); }' testlog |awk -F ";" '{print $1}'
 /
/
[root]# setnamearr=($(awk '/saveset name:/ {for(i=3;i<=NF;i++) {gsub("\"",""); printf( "%s ", $i )}; printf( "\n"); }' testlog |awk -F ";" '{print $1}'))
[root]# echo "${#setnamearr[@]}"
2
[root]# for ((i=0; i<"${#setnamearr[@]}"; i++)); do
> echo "${setnamearr[i]}"
> done
/
/
[root]#


Last edited by Scrutinizer; 12-28-2016 at 10:00 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Has anyone seen this issue with the /dev/null?

hello all, I am working in a Hpux 11.0 64 bit environment. I am not sure if a third party software is doing this or not, but the admin to this server says it is not a server issue as he has check and double check logs and crons to verify this issue. My problem, is that every now and then, once... (4 Replies)
Discussion started by: oott
4 Replies

2. Shell Programming and Scripting

PHP: how can I delete empty/NULL elements from a multi-dimensional array.

Hi all I have a file that i'm running and exec(cat ./dat) against..and putting its contents into any array, then doing an exploding the array into a multi-dimension array... The 15 multi-dimensional arrays have elements that are null/empty, I would like to remove/unset these elements and then... (2 Replies)
Discussion started by: zeekblack
2 Replies

3. Shell Programming and Scripting

Insert string 'NULL' where there is a null value

I have an input file having 7 fields delimited by , eg : 1,ABC,hg,1,2,34,3 2,hj,YU,2,3,4, 3,JU,kl,4,5,7, 4,JK,KJ,3,56,4,5 The seventh field here in some lines is empty, whereas the other lines there is a value. How do I insert string NULL at this location (7th loc) for these lines where... (8 Replies)
Discussion started by: zilch
8 Replies

4. Shell Programming and Scripting

Inserting a string in another sting

Hi Experts, I need to insert a sting into another string at a specified position. Like the below. Regards, Tin-Tin (3 Replies)
Discussion started by: tinufarid
3 Replies

5. Programming

Checking an array for NULL in C++

Hello All, I have this question that how to check for an array for NULL? For eg. #include<iostream.h> using namespace std; int main() { char arr; if(arr == NULL) { cout<<"NULL"; } } Thanks a lott in advance!!! (3 Replies)
Discussion started by: mind@work
3 Replies

6. Shell Programming and Scripting

PERL : Read an array and write to another array with intial string pattern checks

I have an array and two variables as below, I need to check if $datevar is present in $filename. If so, i need to replace $filename with the values in the array. I need the output inside an ARRAY How can this be done. Any help will be appreciated. Thanks in advance. (2 Replies)
Discussion started by: irudayaraj
2 Replies

7. Shell Programming and Scripting

Issue with null value

Hi, I am trying below code. let me explain what is going on here. xmitq=`echo "dis qr($queue) xmitq"|runmqsc $QMGR| tr ' ' '\n' | sed 's/^*//g'|grep "XMITQ"| cut -d '(' -f2| cut -d ')' -f1` chl=`echo "dis chl(*) xmitq"| runmqsc $QMGR |egrep 'CHANNEL|XMITQ'|\ egrep -v... (6 Replies)
Discussion started by: darling
6 Replies

8. Shell Programming and Scripting

working with null elements in an array

i have an array (with each element length "n") which is dynamic and has alphanumeric characters. i want to check if any of the elements of the array are null and replace it with a string of "n" zeros for that element. can you suggest me a code for the same. (1 Reply)
Discussion started by: mumbaiguy07
1 Replies

9. AIX

/dev/null file issue

Hi Experts, I Have a query. In one of my server I just came to know that there was /dev/null file which is a not a character file. Its just a normal file. I know the command to create the character file (/dev/null) but what is the procedure. Like should i delete /dev/null and create or... (7 Replies)
Discussion started by: jayadeava
7 Replies

10. Shell Programming and Scripting

Finding null column value using array

hi, Am trying to find a solution for finding a null column value inside a loop using array. for eg: two three five From the above array myarray,myarray and myarray having null values. But when am trying to check that space using some condition its not working. for (( i=0;... (4 Replies)
Discussion started by: rogerben
4 Replies
cuserid(3C)						   Standard C Library Functions 					       cuserid(3C)

NAME
cuserid - get character login name of the user SYNOPSIS
#include <stdio.h> char *cuserid(char *s); DESCRIPTION
The cuserid() function generates a character-string representation of the login name under which the owner of the current process is logged in. If s is a null pointer, this representation is generated in an internal static area whose address is returned. Otherwise, s is assumed to point to an array of at least L_cuserid characters; the representation is left in this array. The constant L_cuserid is defined in the <stdio.h> header. In multithreaded applications, the caller must always supply an array s for the return value. RETURN VALUES
If the login name cannot be found, cuserid() returns a null pointer. If s is not a null pointer, the null character `' will be placed at s[0]. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
getlogin(3C), getpwnam(3C), attributes(5) SunOS 5.11 30 Dec 1996 cuserid(3C)
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy