Questions tagged [null]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
54 views

Remove all zero bytes from file in Unix

I've got a file of data from a prototype hardware RNG, however, for some reason it's producing a lot of 0x00 bytes. I want to delete all of these 0x00 bytes so I can test if the rest of the data is ...
0
votes
1answer
50 views

If Bash arrays can't contain a null string, how does this array do it?

I've recently discovered that you can't pass a null string to a Bash array. This is tricky, as I'm trying to insert an empty string value into an array. I've noticed that the Bash completion variable ...
1
vote
1answer
51 views

how to write a pgrep pattern that (never) matches a zero byte?

I'd like to kill a process with a long name that ends with foo. Currently my plan is to use pkill (though for testing, to be friendly to the process, I've been checking my patterns with pgrep instead)....
2
votes
3answers
97 views

awk: Exact string match on field not working with NUL as record separator

Given a file with newlines in fields (embedded by double quotes), I tried to use NUL as record separator and then select desired records. For this I have replaced the ends of lines with NUL and then ...
8
votes
1answer
1k views

Send null byte in unix pipe

I am trying to redirect python generated input to ELF 64-bit executable in bash 5.0.3. I am getting: > ./bf <<< $(python2 -c "print('c'*6+b'\x00'+'c'*6)") bash: warning: command ...
0
votes
1answer
282 views

Docker: bash: /dev/null: Permission denied

I use docker to unpack a linux chroot and then execute commands into it, but I get this inside the chroot. echo ciao > /dev/null bash: /dev/null: Permission denied I thought that the null device ...
6
votes
2answers
972 views

Are shells allowed to ignore NUL bytes in scripts?

Because that's what some of them are doing. > echo echo Hallo, Baby! | iconv -f utf-8 -t utf-16le > /tmp/hallo > chmod 755 /tmp/hallo > dash /tmp/hallo Hallo, Baby! > bash /tmp/hallo /...
0
votes
5answers
140 views

How to monitor changes in file filled by null bytes?

I have a 10Mb file filled by null bytes. A program is accessing it and changes zeros to specific strings up to the end of the file. I've tried to use tail -F | grep wanted_text | grep -v "...
15
votes
2answers
2k views

Create virtual block device which writes to /dev/null

I want to test some physical links in a setup. The software tooling that I can use to test this require a block device to read/write from/to. The block devices I have available can't saturate the ...
0
votes
1answer
69 views

How to nullify the /var/log/message file as a normal user

Is it possible to truncate the /var/log/messages file as a normal user? If yes what permissions do we need to mention in sudoers file for this?
0
votes
1answer
133 views

command stdout to /dev/null

I have very simple command which generating STDOUT which i want to do /dev/null but somehow it's not working or i am missing something here. $ ldapsearch -Y GSSAPI -b "cn=users,cn=accounts,dc=...
2
votes
2answers
421 views

Printing only the value and excluding null

I'm trying to print the json output using jq, But I'm getting null How can I print only access_key and secret_key, but not null? $ cat sample.json | jq '.' { "access_key": "...
2
votes
2answers
69 views

Remove values from NUL separated file

I have an array of values v that I want to remove from the file f. f is NUL delimited. How do I proceed? I tried using sd, but it didn't work. Example: I have this file: # cat -v $attic ^@this is 1....
0
votes
1answer
360 views

How to assign a zero-length, non-null string

Based on this, amongst many other things I've read, my understanding is that a='' makes a both null and zero-length. But, then, how does one create a zero-length, non-null string? Or, is there no ...
22
votes
2answers
2k views

Why does tar appear to skip file contents when output file is /dev/null?

I have a directory with over 400 GiB of data in it. I wanted to check that all the files can be read without errors, so a simple way I thought of was to tar it into /dev/null. But instead I see the ...
0
votes
0answers
55 views

Compare file compression methods by sending to /dev/null

I'd like to compare the time to completion for compression algorithms and parameters. I'm confident that the inputs will be set up properly. In order to save space and avoid some variability my ...
2
votes
5answers
262 views

remove all lines with nullbytes/corrupt data

So I recovered a text file from an old hdd, but I failed to completely recover all of the data. The data that wasn't correctly recovered has returned as null bytes. How can I remove every line from ...
26
votes
1answer
3k views

Why don't reads from /dev/zero count as IO_RBYTES?

I am emptying out a hard drive on some Linux 4.x OS using this command: sudo sh -c 'pv -pterb /dev/zero > /dev/sda' And I opened another tty and started sudo htop and noticed this: PID USER ...
1
vote
0answers
218 views

Odd Characters in Log File

I checked my cron log files today for a script that I have scheduled and the saw the following errors/characters: \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\ ...
4
votes
1answer
452 views

With gnu find, what is the difference between -print0 and -printf “%p\0”

In a terminal I can run... find . -type f -print0 ./testdir/testfile2.txt./testdir/testfile.txt And then... find . -type f -printf "%p\0" ./testdir/testfile2.txt./testdir/testfile.txt They both ...
2
votes
4answers
2k views

How to use the NUL character as a separator in sed substitute and delete commands?

This is what I tried, when intending to replace /path/to/a with /path/to/b using NUL as the separator/delimiter: $ cat pathsList| sed -r -e 's\0/path/to/a\0/path/to/b\0g' sed: -e expression #1, char ...
115
votes
9answers
23k views

Why is /dev/null a file? Why isn't its function implemented as a simple program?

I am trying to understanding the concept of special files on Linux. However, having a special file in /dev seems plain silly when its function could be implemented by a handful of lines in C to my ...
1
vote
1answer
413 views

random “NULL character(s) present” error in exim

Sometimes we are getting NULL character(s) present errors on incoming mail. It looks like this: 2018-03-01 12:26:51.244 [22933] SMTP syntax error in "RCPT TO:" H=mail-wm0-f56.google.com [74.125.82.56]...
2
votes
3answers
3k views

Remove null bytes from the end of a large file

I just backed up the microSD card from my Raspberry Pi on my PC running a Linux distro using this command: dd if=/dev/sdx of=file.bin bs=16M The microSD card is only 3/4 full so I suppose there's a ...
1
vote
2answers
2k views

Working with /dev/null with cat or cp vs touch

In a tutorial about public key infrastructure the author sets up a database to work with when setting up a Root Certificate Authority: cp /dev/null ca/root-ca/db/root-ca.db cp /dev/null ca/root-ca/db/...
0
votes
1answer
2k views

What happens when you write to /dev/null? What’s the point? [duplicate]

Tried echo "Some text" >> /dev/null then cat null with no output. Can someone explain why this is?
7
votes
3answers
3k views

Using binary data as a parameter in bash - any way to allow nuls?

So I'd like to pass the first 512 bytes of binaryFile.dd as the second parameter to myProgram but bash strips out all the NUL chars. Is there any way to avoid this in bash or am I on a hiding to ...
6
votes
3answers
2k views

How to prevent word splitting without preventing empty string removal?

I need to pass as a program argument a parameter expansion. The expansion results in a filename with spaces. Therefore, I double-quote it to have the filename as a single word: "$var". As long as $...
5
votes
1answer
7k views

Can I safely ignore: “warning: command substitution: ignored null byte in input”?

Is it possible to safely ignore the aforementioned error message? Or is it possible to remove the null byte? I tried removing it with tr but I still get the same error message. this is my script: #!/...
0
votes
2answers
11k views

cp large file to /dev/null to reduce size to zero [closed]

I just came across the advice that if you want to get rid of a large file and a process has the file handle open you should copy it to /dev/null and its size will be reduce to zero. How does this ...
4
votes
2answers
89 views

Invert matching lines, NUL-separated

I’m writing something that deals with file matches, and I need an inversion operation. I have a list of files (e.g. from find . -type f -print0 | sort -z >lst), and a list of matches (e.g. from ...
2
votes
2answers
83 views

How can I get FreeBSD `patch` to tolerate null bytes?

The patch of the final line fails on FreeBSD 10.2, but works on GNU: #!/bin/sh echo a > f1 printf '\0' >> f1 echo c >> f1 cp f1 f2 echo d >> f2 diff -au f1 f2 > diff patch <...
0
votes
3answers
236 views

Null value than rename file

I have a shell to a task but I should handle the null value in this. So in the task i cut the part of a word and i delete or rename the file, but need another if element for null. For example: I ...
8
votes
4answers
25k views

Null and escape characters

I know that a filename in Linux has no restriction whatsoever except for two characters '/' and '\0'. I know that '/' is prohibited because it is a directory separator but is there any other reason ? ...
5
votes
2answers
15k views

Meaning of `cat /dev/null > file`

In a document created by a former coworker there is this command: cat /dev/null > /var/spool/mail/root It says next to it that it will clean out mailbox. Can someone please explain how/why ...
37
votes
1answer
28k views

How do I use null bytes in Bash?

I've read that, since file-paths in Bash can contain any character except the null byte (zero-valued byte, $'\0'), that it's best to use the null byte as a separator. For example, if the output of ...
0
votes
2answers
1k views

How do I enable &>/dev/null by default for all sh/bash commands?

Is there a way to make &>/dev/null the default behavior in a sh/bash script? I' rather not have to appended this to every command within the console, not an *.sh script. I'm looking to make a ...
208
votes
6answers
494k views

redirecting to /dev/null

I'm reading an example bash shell script: #!/bin/bash # This script makes a backup of my home directory. cd /home # This creates the archive tar cf /var/tmp/home_franky.tar franky > /dev/null 2&...
7
votes
3answers
680 views

Are there “esoteric” (weird) but standards-compliant C compilers or runtimes?

As we know, the C standard does not specify a lot of details of the implementation, for example value of NULL pointer, order of bits and bytes (endiannes), alignment in structs and of stack parameters,...
24
votes
3answers
7k views

mv a file to /dev/null breaks dev/null

If I do: touch file; mv file /dev/null as root, /dev/null disappears. ls -lad /dev/null results in no such file or directory. This breaks applications which depend on /dev/null like SSH and can be ...