Delete specific line containing null after '='

Hi,
I'm genrating a file from sql and the file looks like :

$value1=A
$value2=B
$value3=
$value4=
$value5=C

I want to delete those two lines which has Null after '='. Could you please guide me how to do it either using sed or awk ?

Try...

awk -F= '$2' infile

And a sed one.

sed /=$/d file

Great guys..thnx a lot..

Pure shell solution:

  
(04:25:18\[D@DeCoBox15)
[~]$ cat test
$value1=A
$value2=B
$value3=
$value4=
$value5=C

  IFS="=";
    while read test result; do
        if [[ -n $result ]]; then
            echo "$test=$result";
        fi;
    done < test

$value1=A
$value2=B
$value5=C

grep -v "=$" urfile

in the same script i'm also creaeting list files and i'm using the following command for that.

awk 'BEGIN {while (++i < ARGC) printf "%s\n", ARGV}' * > InfaFileList.lst

Since i can expect file names to contain space i'm using the above code. But the problem is the list file is getting created with directories name also, which i don't want. I just want to create file list containg the name of all the files not directories.
Could you please guide me?

use command basename,

for i in $(cat InfaFileList.lst)
do
  basename $i
done

---------- Post updated at 10:03 AM ---------- Previous update was at 09:57 AM ----------

for i in $(cat InfaFileList.lst)
do
 echo ${i##*/}
done

I think i was not able to explain my problem correctly. I have file names containing spaces and also few directories in the same location. I want ot create a file list with all file names(no dir name should be there).
Your code won't help in this case.

Try:

find .  -name "*" -type f | sed 's!.*/!!g'
1 Like