Programming :: Reading And Writing White Spaces To A File?

Dec 2, 2010

I am trying to read a file character wise and trying to write the same character to another file. In this process, I unable to read and write white spaces successfully to the new file. The script reads the white spaces but while writing the white space is lost. The section of the code, is given below. Please advice how can i read and retain the white space while writing to a new file.

Code:

if [ -s f_test.txt ] && [ -f f_test.txt ]; then
echo "File Exists !!"
while read -n1 char; do

[code]....

View 2 Replies


ADVERTISEMENT

Programming :: Zip A Variable With PERL Without Reading Or Writing A File?

Jun 20, 2010

There is the Archive::Zip I think I can use with Perl 5.10 but I don't know how. I don't want to read or write any files, just zip something in memory, with best compression, like

$text = "this is a test";
$zippedtext = &Zip($text);
sub Zip {

[code]...

I guess it's only a few lines.

View 3 Replies View Related

Programming :: If Statement Regex Match For White Spaces?

Apr 8, 2011

I want to match for this string:

Code:

Content-Transfer-Encoding:[:space:]base64
Content-Disposition:[:space:]attachment;[:space:]filename="%variable%"

Both lines are new lines, so they won't be inline. Other than that, they are all constants, I want this regex match to be an if statement rather than returning match string. so if the $content variable contains some string that matches:

Code:

if `sed "//p"` ;

View 4 Replies View Related

Programming :: Unix Command To Remove White Spaces?

Sep 18, 2010

Im using this unix command(in a php file) to remove a certain string and then remove the whitespace left by that string. Unofrtunately in many cases, the files get completely erased. Is there a workaround?

Code

<?php
$dir = "./";
$rmcode = `find $dir -name "*.php"

[cod3e]....

View 14 Replies View Related

Debian :: Delete Back Over White Spaces They Stay White Out?

Oct 10, 2010

here is what is in my file:

[code]...

i have xterminus installed. i also have a white block over the first letter in my username and when i begin typing, the 'block-type cursor' just leaves full white spaces behind and i cannot read my text at all. even when i delete back over the white spaces, they stay whited out.

View 4 Replies View Related

Programming :: Reading And Writing Text Files In C?

Jan 1, 2011

Reading and writing text files in C?

View 9 Replies View Related

Programming :: Reading/writing Every Frame On Ethernet?

Dec 3, 2010

I would like to write a program that can read every ethernet frame arriving on a specific hardware NIC, without a TCP/IP stack otherwise doing anything on that NIC. Likewise I want to be able to write out to that NIC. So every arriving ethernet frame, of all types, would be readable (probably one at a time to preserve frame boundaries). And every write of exactly that same data would send frames out. The data read and written would be the whole ethernet frame. The kernel would do nothing else with this data, but other NICs would still operate as usual.

What I would be doing is that on 2 separate NICs, copying frames from one to the other, as in bridging. But I would also be doing modifications per what my program needs to do (not at liberty to say what that would be). What facility would I need to be looking at to do this? There is no ethernet device file. Would raw sockets be able to do this? The programming language will be C.

View 4 Replies View Related

Programming :: Writing And Reading Driver Value In Ioctl?

Jan 18, 2011

I just want to read and write some values (integer) to my driver. I used put/get user but always getting errors.

driver

Quote:

int Wert;
static int device_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsinged long arg)
int ret;

[code]...

Quote:

int WERT
ret=ioctl(fd, SETIT, WERT)
ret=ioctl(fd, GETIT, WERT)

if i say in C++ WERT is 5 the value arg of the driver becomes 5 but not WERT the returnvalue of get and put user is -1 so it failed.

View 12 Replies View Related

Programming :: Multithreaded Reading And Writing Of A Shared Integer?

Nov 4, 2010

It it safe to read a shared integer while another thread is writing to it on a multicore system?

View 3 Replies View Related

Programming :: Writing To And Reading From A Socket From Bash Script?

Mar 11, 2010

Here the description of the issue I am having.I am writing a bash test script which reads lines from a file, builds ISO messages, sends them to a server, reads the response with response code and reports the result of the test to a file or on the screen.The message that I need to send is 94 characters long.Here's the portion of a code that I initially wrote:

~ Open socket.
exec 3<>/dev/tcp/172.26.0.25/9991
#~ Send msg.

[code]...

View 7 Replies View Related

OpenSUSE Install :: Mount A Live Compressed File System For Reading & Writing From A LiveCD/DVD Image?

Jul 9, 2011

On a Linux CD/DVD, there are compressed filesystem images for the live version for KDE or Gnome for example, but they have no extension, but they are clearly an image file ( compressed filesystem images for the live version before installation ) !!

I was wondering, How do I mount these compressed filesystem images, after I copy the ISO content of the CD/DVD on my system .... I want to edit some files or packages and make some changes, like if I want to customize a live version of gnome for example ! ... ( I know you might be tempted to tell me to use KIWI etc to customize etc ..... ) ... but I want to be able to mount the compressed file system image, then edit it for reading and writing while it is in a subdirectory on its own ... i want to open it ! ... is there a way to do this ??? ... these type of files have no extension ...

i can open this compressed filesystem image then to edit for read & write ... before I roll it back again ..... If and when I succeed .... what should I watch out for ? ... will the same compressed file image but slightly modified work again ?

PS. that same question could be kind of translated or be extended like : how do I use unionfs/squashfs programs on the command line to mount these image files with no extension for read & write mode ???

View 9 Replies View Related

Programming :: Line By Line Reading And Writing In Bash?

Nov 29, 2010

I have a text file (myfile.txt) with columns a,b,c.

123 2 23
124 2 24
125 2 22

[code]...

View 4 Replies View Related

Programming :: Bash File Names With Spaces?

Jul 24, 2010

I have a laptop that I am in through SSH. The laptop does not have an Xwindow system so I am using the program fbi to open an image on my laptop screen from my SSH connection:

fbi -T 8 picture.jpg #this opens the image on the laptops tty8 terminal

I've found that making a for loop does not work with files that contain a space in the name. Something to due with a bug that they call a "feature" that stops the first variable at the first whitespace.

Using a "while" loop is not exactly what i require either seeing as I want to be able to view each image in the directory on screen and tag it accordingly, before it jumps off to the next image, and I'm not sure how to add a pause to a while loop.

How do I make a Bash script and loop Variables handle files like "files that contain spaces.jpg"

View 5 Replies View Related

General :: Shell - Rename A File From Something Without Spaces To Something Containing Spaces?

Jan 26, 2010

Is it possible, in Linux, to rename a file from something without spaces to something containing spaces? I know I can create directories and files with spaces by doing:

mkdir "new dir" and:

touch "new file.txt"

I want to rename files from:

imgp0882.jpg to something like:

20091231 1243 some topic.jpg

And how would it look in a shell script that uses parameters like:

for i in *.jpg do
rename "$i" "$somepath/$mydate $mytime $mytopic$extension"
?

I'm new to Linux (using PCLinuxOS 2009.2), coming from Windows, and I've written myself a little shell script to download files from my camera and then automatically rename them according to a date-and-topic pattern. As you can guess by now, I'm stuck on the bit about renaming. If you want to see my script, here's a copy. I'm not using jhead for this renaming because that only works with JPEG files but I want a single solution for any media format including videos.

View 2 Replies View Related

Programming :: Replace Spaces With Underscores In File Names?

Jan 11, 2011

I often get files with many spaces as part of their names. I would like to automatically replace these spaces with underscores, but otherwise not change the file name. Is there a way to do this task with just the bash shell?

View 4 Replies View Related

Programming :: Rename File Names : Replace Dots By Spaces, Keep The Extension?

Mar 28, 2011

I am trying to rename a lot of files but need to keep the extension :

the files are films names :

a.b.c.d.***.iso

the result should be replacing "." by spaces " "

this command :

for files in *.iso ; do mv "$files" `echo "$files" | tr '.' ' '`; done

put a space also before the extension iso ??

How can I rename files from

"a.b.c.d.iso" to "a b c d.iso"

View 5 Replies View Related

General :: Dd Gets Slower While Reading And Writing?

Jan 25, 2011

user@user-laptop:~$ sudo dd if=sd_backup of=/dev/sdd bs=4M conv=noerror,sync

205520896 bytes (206 MB) copied, 28.564 s, 7.2 MB/s
247463936 bytes (247 MB) copied, 57.1285 s, 4.3 MB/s
260046848 bytes (260 MB) copied, 73.2388 s, 3.6 MB/s
289406976 bytes (289 MB) copied, 104.121 s, 2.8 MB/s

[Code]....

How come dd gets slower after copying this 8GB file? What can I do about it?

View 1 Replies View Related

Programming :: Writing File In Perl/cgi?

Apr 10, 2010

I'm not able to write to a file using my perl cgi script which is as fallows:

Code:
#!/usr/bin/perl -w
use strict;
print "Content-type: text/html

[Code]....

View 4 Replies View Related

OpenSUSE Network :: Direct NAS Reading And Writing?

Feb 9, 2010

I've been able to get access to our Netgear NAS, I can browse it, copy files etc. just fine. But I don't have "direct access" in as far as, Open Office won't open any files residing on the NAS, neither can I save directly to the NAS form a program and when I get a "Browse for File" form field on a website (eg attachments in GMail etc.), I can't browse to the NAS either. My XP box does do all of this, either through my mapped network drive or even through browsing the network. How can I make openSuse 11.2 use the NAS with my login credentials as if it was a local disk?

View 4 Replies View Related

Ubuntu :: Reading/writing Ext3 Partition From XP?

May 9, 2010

I've used ext2ifs drivers to mount my ext3 partition in winxp, but I don't have write acces, it's mounted in a read-only mode, and i didn't check the rad-only box during the installation of the drivers. [URL] It's a straithfoward proces so I dont understand what I did wrong. I'm using fresh xp install with (more or less) all the updates and ubuntu 10.04 Also the partition is mounted at /home, so I dont know if that makes any difference.

View 1 Replies View Related

General :: Reading/writing Ext3 Partiton From XP?

May 9, 2010

I've used ext2ifs drivers to mount my ext3 partition in winxp, but I don't have write acces, it's mounted in a read-only mode, and i didn't check the rad-only box during the installation of the drivers.I've used help from the official site http://www.fs-driver.org/and this tutorial http://www.dedoimedo.com/computers/l...s-windows.html
It's a straithfoward proces so I dont understand what I did wrong.I'm using fresh xp install with (more or less) all the updates and ubuntu 10.04Also the partition is mounted at /home, so I dont know if that makes any diferance.

View 3 Replies View Related

Security :: Reading/writing Encrypted NTFS?

Jul 25, 2010

My main workstation incorporates a mixture of ext3, ext4, and NTFS partitions scattered across a number of hard drives. Several of the ext4 partitions are encrypted, and I intend to encrypt the rest of the Linux partitions in the near future.I run VMware workstation, with several Windows OS guests, including Win2K, WinXP and Win7. My Win7 VM is installed on a virtual hard disk, and that virtual hard disk is encrypted using VMware facilities.So this leaves me with a bunch of NTFS partitions that are not encrypted. These are physical partitions on a couple of different hard drives. The reason I have them is ancient and historical, and as I have upgraded my system over time I have maintained the architecture due to the extreme difficulty of rearranging Windows systems.I still need to maintain Win2K and WinXP support, and rearranging those virtual machines would represent a hideous nightmare for me; I really want to maintain the same hard drive partition architecture.But I want to encrypt the NTFS partitions, in a fashion that can be handled by any of the Windows operating systems, AND can be accessed for read and write from Linux.Is this possible? If not using Windows facilities (I don't think ntfs-3g handles encryption, and there are known backdoors in the Windows facilities anyway), is there any third party solution that would work? Would True Crypt do the job in a fashion that would permit access from all the various operating systems, as required? I do generally mount the NTFS partitions in whichever Windows VM is appropriate, then share them out via SMB, but there are circumstances (like when a VM is not running) where I will directly hit them from Linux. So, it is possible for me to contemplate a solution that only works from Windows, but this would cost me the ability to repair/modify those filesystems directly from Linux, which under certain circumstances (a malfunction of the VM, for instance) could be a problem.

View 2 Replies View Related

Software :: Reading/Writing To Serial Ports (Rs-232)?

Dec 5, 2008

I am about to write a program to listen and read data from /dev/ttyS0 and write the data to /dev/ttyS1 after processing. Also, the same time I need to listen to /dev/ttyS1 and write to /dev/ttyS0 if any data arrived at /dev/ttyS1.

View 9 Replies View Related

Slackware :: Reading And Writing Emails From The Console?

Apr 3, 2010

I want to be able to access my email account from the console. I'm reading all day about fetchmail, postfix, sendmail etc. but all the stuff I found is related to building whole mail system. All I want to do is to read my emails and write some. Which is the painless way to do this? I successfully configured Evolution for this purpose but I want to do that from the console.

View 10 Replies View Related

Programming :: [C++] Writing Double Value To A Text File?

Jun 3, 2011

Code:
int main ()
{

[code]...

View 9 Replies View Related

Server :: Shortlist Processes Which Are Writing / Reading To / From Disks?

Apr 2, 2010

At times I see heavy hard-disk activity slowing down system.I have enough RAM and enough of it free.Apparently I am not doing anything that should cause this.'vmstat' shows high numbers for "bi bo" I want to find out which processes are doing "bi bo".How can I zero in on the particular processes?What command?

View 3 Replies View Related

Programming :: Reading File - Output From Xrandr -q

Jul 24, 2010

Code:

I'm trying to make several files: each named after the display and containing resolutions. But for some reason I get null when trying to read lines.

View 2 Replies View Related

Programming :: Reading A Binary File Which Is In Hexadecimal

Jan 9, 2011

I have a binary file, which I need to process using my C++ application. Only thing I know is first chunk of the file is long, second chunk is int, third chunk is char etc... The binary file actually contains something like below. (which is represented in hex base).

D7 07 00 00 00 00 00 00 37 18 00 00 DE 07 ............ so on.....

I need to procees the file in the following way.

* I know the first data segment in my file is long. So it takes 4 bytes.
* so I need to read the first four bytes. That is D7 07 00 00.
* Then I need to reverse this as 00 00 07 D7.
* Finally I need to get the decimal value of above hexa decimal line. ( 00 00 07 D7)
* i.e. 00 00 07 D7 (in hex) = 7D7 (in hex- after removing leading 0 s) = 2007 (in decimal)

Like wise I need to process the whole file.

View 14 Replies View Related

Programming :: Reading Text File Into An Array

Oct 20, 2010

I know that this is a really simple thing to do but I just can't figure it out. How do I read a text file into an array in C++?

View 3 Replies View Related

Programming :: Reading A File Of Data In An Array?

Feb 10, 2011

I have two files of data with different numbers of columns and rows. I want to read this two files in two arrays and then compare for example the second column of first data file with the third column of the other text file and if the difference between of two numbers is less than a threshold then the program print the information in the rows which fulfill this condition in the third text file. I have written below program but the problem is that it does not go through all rows of second file.

declare -a a
declare -a b
r=` awk '{n++} END {print n}' second.txt `
echo $r
awk '
{

[Code]....

Actually I have two data files one of them contains 44406 and the other one has 12066 rows and I want to check whether the difference between the components of two specific columns is less than a threshod but I have simplified it here. I had written this code and then I have realized that this code just goes through the number of rows as the same as the first.txt file and ignores the rest. I could not find the problem yet.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved