Skip to contentSkip to conversation

File size

DISCUSSION Anindya Mozumdar 13 participants 17 messages Aug 8, 2004 – Aug 10, 2004

lore
Share & tools
lore
#0 lore raw

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.

#1 lore raw

Am So, 2004-08-08 um 11.00 schrieb Anindya Mozumdar:

Quoted 3 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?

echo -n "">foo

Quoted 7 lines

Anindya.
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Anindya Mozumdar

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

#3 lore raw

You can make a file zero length by cat > foo and by typing CTRL-D

Quoted 15 lines · Roberto Vanto

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 8 lines
 Regards, 
 Aroop M.P
 Bobcares Support Team
 ---------------------------------------------------
 "NO MATTER WHERE YOU ARE IN THE WORLD,IF YOU HAVE DECIDED TO DO  SOMETHING 
DEEP FROM YOUR HEART YOU CAN DO IT. IT HAS ALWAYS BEEN THE   THOUGHT THAT 
MATTERS... "
 ---------------------------------------------------
#6 lore raw
In reply to Roberto Vanto

Am So, 2004-08-08 um 13.44 schrieb Roberto Vanto:

Quoted 10 lines

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

touch changes the timestamp if the file exists. It sounds like the file already exists. btw, You don't need to delete it through an editor, "rm foo ; touch foo" would do it, too. ;-)

Quoted 7 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw
In reply to Anindya Mozumdar

cp /dev/null somefile

Quoted 8 lines · Anindya Mozumdar
Quoted 8 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

End of included message

Signature · 5 lines
+--------------------------+------------------------------+
| Tim Walberg              | [email protected]      |
| 830 Carriage Dr.         | www.mindspring.com/~twalberg |
| Algonquin, IL 60102      |                              |
+--------------------------+------------------------------+
#7 lore raw
In reply to Sascha Retzki

How can i attach one file on the top of another file.

Suppose file1 has 10 lines and file2 has 20 lines. I want to attach the 10 lines of file1 to file2 so that the file2 will have 30 lines in total.

Quoted 25 lines · Sascha Retzki

Am So, 2004-08-08 um 13.44 schrieb Roberto Vanto:

Quoted 10 lines

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

touch changes the timestamp if the file exists. It sounds like the file already exists. btw, You don't need to delete it through an editor, "rm foo ; touch foo" would do it, too. ;-)

Quoted 4 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 8 lines
 Regards, 
 Aroop M.P
 Bobcares Support Team
 ---------------------------------------------------
 "NO MATTER WHERE YOU ARE IN THE WORLD,IF YOU HAVE DECIDED TO DO  SOMETHING 
DEEP FROM YOUR HEART YOU CAN DO IT. IT HAS ALWAYS BEEN THE   THOUGHT THAT 
MATTERS... "
 ---------------------------------------------------
#8 lore raw

Am So, 2004-08-08 um 15.10 schrieb Aroop MP:

Quoted 5 lines

How can i attach one file on the top of another file.

Suppose file1 has 10 lines and file2 has 20 lines. I want to attach the 10 lines of file1 to file2 so that the file2 will have 30 lines in total.

cat file1 file2 >file3

Quoted 26 lines · Sascha Retzki
Quoted 25 lines

Am So, 2004-08-08 um 13.44 schrieb Roberto Vanto:

Quoted 10 lines

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

touch changes the timestamp if the file exists. It sounds like the file already exists. btw, You don't need to delete it through an editor, "rm foo ; touch foo" would do it, too. ;-)

Quoted 4 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw
In reply to Aroop MP

To append file1 to file2 do:
cat file1 >> file2

Simple way to empty a file or make an empty file (bash or ksh) do:

Quoted 1 line

file

Quoted 22 lines · Aroop MP

How can i attach one file on the top of another file.

Suppose file1 has 10 lines and file2 has 20 lines. I want to attach the 10 lines of file1 to file2 so that the file2 will have 30 lines in total.

Quoted 16 lines · Sascha Retzki

Am So, 2004-08-08 um 13.44 schrieb Roberto Vanto:

Quoted 10 lines

Anindya Mozumdar ha scritto:

Quoted 5 lines

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-

man touch

touch foo

touch changes the timestamp if the file exists. It sounds like the file already exists. btw, You don't need to delete it through an editor, "rm foo ; touch foo" would do it, too. ;-)

Signature · 4 lines
John Julian
Computer Geek
cell: 248-787-2221
pager: 800-621-4951
#12 lore raw

Re:

In reply to Debian UserJens Suelwald

no
----- Original Message -----
From: "Debian UserJens Suelwald" <[email protected]>
To: <unlisted-recipients:>; <no To-header on input>
Cc: <[email protected]>
Sent: Sunday, August 08, 2004 11:45 AM

Quoted 6 lines

unsubscribe linux-admin

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw
In reply to Anindya Mozumdar
Quoted 3 lines · Anindya Mozumdar

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?

LMAO

If you are trying to get answers to a test or have us do your home work for you, this is probably not the best place to do it. Here you will find SysAdmins, not all are schooled and many times you will find answers here that do not agree with your school book.

For stuff like this you should try [email protected]

Although, you may find a lot of bored SysAdmins here, giving you all kinds of strange answers (some that are even wrong), this is not the appropriate place. As funny as it is, people should not give wrong answers, and less then knowlegdeable SysAdmins should not either.

BTW, "cp /dev/null > myFile" works, but may need to be contested to give you accurate points on a test. Depending on your shell, probably, a simple ">myFile" will be the proper response.

#4 lore raw

Re: File size (shortest possible solution) + don't touch

In reply to Aroop MP

the shortest possible:
> somefile
(( redirect the output of no command at all to somefile ))

Although not necessary, I'll often go
true > somefile
True does nothing other than return success. The reason why I like using it is that it makes a placeholder so that a reader knows that something (or rather explicitly nothing) is happening.

Touch doesn't work.. If the file already exists, it will simply change the last mod-time. without altering the contents

The original purpose of touch (I think) was to convince make(1) that something needed to be done.

Quoted 4 lines · Anindya Mozumdar

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.

Signature · 4 lines
Stephen Samuel +1(604)876-0426                [email protected]
		   http://www.bcgreen.com/~samuel/
   Powerful committed communication. Transformation touching
     the jewel within each person and bringing it to light.
#5 lore raw

Re: File size (shortest possible solution) + don't touch

How about
: > file
'' : '' does really absolutely nothing

daniel

Am Mo 09.08.2004 23:14 schrieb Stephen Samuel <[email protected]>:

Quoted 34 lines

the shortest possible:
> somefile
(( redirect the output of no command at all to somefile ))

Although not necessary, I'll often go
true > somefile
True does nothing other than return success. The reason why I like using it is that it makes a placeholder so that a reader knows that something (or rather explicitly nothing) is happening.

Touch doesn't work.. If the file already exists, it will simply change the last mod-time. without altering the contents

The original purpose of touch (I think) was to convince make(1) that something needed to be done.

Quoted 4 lines · Anindya Mozumdar

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.

--
Stephen Samuel +1(604)876-0426 [email protected]
http://www.bcgreen.com/~samuel/
Powerful committed communication. Transformation touching
the jewel within each person and bringing it to light.
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#15 lore raw
In reply to Anindya Mozumdar
Quoted 3 lines · Anindya Mozumdar

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?

One more voice in the crowd...

:>foo

After we've helped you with your homework, do we get to put our hand up your sweater?

#16 lore raw
In reply to Anindya Mozumdar

Hi,
Thanks very much for your replies. However, this was not any homework or assignment. This arose mainly from an argument regarding touch with a fellow linux user, and since we did not have access to any machine running linux, the best solution was this mail.

In fact, someone did give a wrong solution with touch, which was precisely the point of argument. The mail was sent in the form below so that we can get to know the other unnoticed ways, hoping that someone mentions touch as a solution.
Anindya.

Quoted 8 lines · Anindya Mozumdar

Hi,
How can I make a file zero length without deleting the contents of the file manually through an editor ?
Anindya.
-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html