insert null in unix files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers insert null in unix files
# 1  
Old 02-12-2008
insert null in unix files

Hi everybody,

How to add null values in unix file?

This is what was asked to me in an interview.
# 2  
Old 02-12-2008
maybe:

cat /dev/zero > test.txt

or

cat /dev/null > test.txt

??


Quote:
Originally Posted by sachin.gangadha
Hi everybody,

How to add null values in unix file?

This is what was asked to me in an interview.
# 3  
Old 02-12-2008
Appending nul characters in UNIX

Quote:
Originally Posted by sachin.gangadha
Hi everybody,

How to add null values in unix file?

This is what was asked to me in an interview.
The previous poster should have said (for SH shells)

Code:
dd if=/dev/zero bs=1 count=<count> >> outfile.txt

Because you want to append some zero values. Cat'ing from /dev/null will give you nothing.

The other way, is if in you're vi/m, you can hit CTRL-V CTRL-@ to get a NUL character. You can also use perl to generate one.
# 4  
Old 02-12-2008
thanks for the reply.

I am not getting what you guys have explained probably bcoz i am jst a beginner.

Once again i am making my question clear. how to add null value to a file?

just wanna create a file with nulls. i dont know whether you can do this unix that is why i need experts like you guyz to answer.
# 5  
Old 02-13-2008
What do you mean by "adding null values to a file" ? What's the required output ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking for null condition in a UNIX variable

i have this code for i in `cat sql_output.txt` do -- some script commands done sql_output.txt has 1 column with employee_ids If the sql_output.txt is null then the do loop should not execute. How can i implement this. for i in `cat sql_output.txt` If i is null or empty then ... (5 Replies)
Discussion started by: rafa_fed2
5 Replies

2. UNIX for Dummies Questions & Answers

Make /dev/null all the files

How can I make /dev/null all the 8640 files that I am getting from this command. find . \( ! -name . -prune \) -type f -name "EXPORT_v1x0*" | awk -F'_' '$6<20120812' And then delete everything. If I am using this command to delete it, I am getting Disk Quota Exceeded Exception. find .... (4 Replies)
Discussion started by: raihan26
4 Replies

3. UNIX for Advanced & Expert Users

How would I create a NULL terminated file in Unix under Bash?

I am testing some file routines against potential "nasty name" Unix files, such as those with a CR, LF, in the middle or NULL terminated, utf multi-byte character. So, under Bash, I want some way of: mv "name" "name\0" with the \0 a real NULL. Against all my efforts, I have not been... (2 Replies)
Discussion started by: drewk
2 Replies

4. 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

5. Shell Programming and Scripting

awk Problem while insert null field to file

Dear All, I have the following input file. I want to replace data with null values. I/P File: 9022334455|2008-12-06 06:10:21|2|Error@@@|esoo8erp| 9024334432|2008-12-06 08:40:59|6|Error@@@|6y2o8e6r| O/P File: 9022334455||2||esoo8erp| 9024334432||6||6y2o8e6r| ... (4 Replies)
Discussion started by: hanu_oracle
4 Replies

6. Shell Programming and Scripting

comparing the null values in the unix

hi all, iam new to this forum.i have to submit the script EOD.so please help me. my requirement is to compare two null values..iam trying to compare two null values :One null value output of the storedprocedure and another iam giving spaces in script. it is giving the error... (11 Replies)
Discussion started by: bbc17484
11 Replies

7. Shell Programming and Scripting

handling null values in files

Hi , I have a script where i will remove header and trailer record and ftp to another server. I'm using the code: latestfilename=`ls filename_* | tail -1` echo "Latest filename = $latestfilename" sed '1d;$d' $latestfilename > a.ftpedfile I have an issue if input data is having null... (1 Reply)
Discussion started by: ammu
1 Replies

8. UNIX for Dummies Questions & Answers

Grep for NULL for a specific field in a unix file

hii.. I have a pipe delimited file For ex: TEST_1-8J6TZN|ASLANK|BHR-09||TRAM I want to grep for NULL in the 4th field only from the above file Please suggest Also let me know if there is any limitation in the suggested command Thanks all in advance..!! (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

9. UNIX for Dummies Questions & Answers

Find files which contain a null character

Hi, I would like to use grep to find files which contain NULL characters. I'm not sure how to represent the null character in the grep statement. Could anyone help please? Thanks! Helen :confused: (5 Replies)
Discussion started by: Bab00shka
5 Replies

10. UNIX for Dummies Questions & Answers

mv files to /dev/null

im having trouble with moving files in a directory into /dev/null for file in $HOME/.trashcan/ do mv $file /dev/null done the error msg i get is: mv: /dev/null: not a directory. does anyone know how to fix this? thanks primal (16 Replies)
Discussion started by: primal
16 Replies
Login or Register to Ask a Question