ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
The trouble is that the spaces need to be escaped. I'm pretty sure the easiest way to do this in a script is to use sed with something like "sed s/ /\ /g". Since I'm new to sed myself bu haven't had a chance yet, to address this problem, I can't offer a working script. I can tell you that there is a perl script named "rename" that exists as a command on some Linux systems. It can be used to replace spaces with something else (e.g. underscore or just deleting the space). I believe it requires a similar syntax.
Oh stupid me, how could I not think of this. And the assignment itself is very secret, I suppose? Please take care not to be overly specific on it, since we here are all pretty eager to train our ability to read other peoples minds.
BTW you may tell your teacher that stuff like ls | grep | awk | ssh | mencoder | wine | finger | echo | halt is *very* bad style. Never do more than or two things in a single line, don't use a pipe if you can use a loop, and there is no need not to use 'find' if there is one. Always keep things simple and readable.
the solution is quite easy, u dont need sed or awk.
u can use the following command
ls -l|tr -s " "|cut -d " " -f x-
tr -s " " is used to suppress multiple spaces, so that u can use a single space in the cut command as your delimiter. now x is the column number from where the names of ur files start. thats it hope it solves ur problem. BTW u from india or what.
using `find` to access files with spaces in their names
Originally posted by Marius2 #!/bin/bash
find . | while read FILE
#Now full name including spaces in $FILE
thank you, Marius! I found my way here because I was trying to wax a windows installation on a laptop. the owner of the laptop wanted to make sure that no one could read her personal info, so I took your script and embellished a little.
boot knoppix and let it rip. maybe a couple times. of course, windows won't boot, but that's to be expected. it's not so fast, but I think it'll get the job done.
find /mnt/hda1 -type f | while read FILE
size=$(stat -c %s "$FILE")
dd if=/dev/random of="$FILE" bs=$size count=1
Originally posted by bahadur can u plz explain a little how ur code is working?
first, I'll say that it looks to me like you're asking us to do your homework for you. at the risk of sounding pedantic, you will learn more if you struggle with this stuff, and not just get the answers handed to you in a forum.
that said, knoppix is a linux distribution that boots from a CD. shove the disk in and restart the computer. very slick. knoppix allows you to mount the existing partitions that exist on the hard drive, and I have mounted the windows partition I'm wiping under /mnt/hda1.
in the script, the output of the find command is piped to the while loop. dd(1) and stat(1) have man pages.