Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Obsolete
Jun 1, 2000

I have a quick grep question.

I have a txt file that has lines that look like:

IM,009-0001,D,0,@xxxxxxx_0907266001;IMAGES\00\00;009-0001.TIF;2
IM,009-0002, ,0,@xxxxxxx_0907266001;IMAGES\00\00;009-0002.TIF;2
IM,009-0003, ,0,@xxxxxxx_0907266001;IMAGES\00\00;009-0003.TIF;2

Basically, all I want to do is strip the zeroes out of the first part (the part immediately after the IM),and change the hyphen to a period.

So, I want to go from:
code:
IM,009-0001,D,0,@xxxxxxx_0907266001;IMAGES\00\00;009-0001.TIF;2
To:
code:
IM,9.1,D,0,@xxxxxxx_0907266001;IMAGES\00\00;009-0001.TIF;2

Adbot
ADBOT LOVES YOU

Obsolete
Jun 1, 2000

I've converted my old desktop PC into an Ubuntu file server that I've thrown in my closet, and I was wondering if there was an easier/better way to administer the files.

Right now, I've got a 20gb home partition, and then two 400gb drives that I'm using to store media on. Every time I want to copy or moves files to or from these drives, I need to use sudo, because I'm not the owner (root is) of the drive. I've since chown'd both drives to be me, and used chmod to make all files 777. However, every time a new file gets added to the drive(s), it makes the owner root. I don't want to have to sudo every single time I want to copy/move/delete something, and I don't exactly feel especially comfortable with having everything chmodded to 777. Is there an easier way to maintain this system?

Obsolete
Jun 1, 2000

Harokey posted:

What are you using to copy the files over to the drive?

Just cp commands. 99% of the time, I access the computer via SSH, so it's mostly just copying files from my laptop/other computers to one of those 400gb drives. rTorrent also downloads files to one of the drives. Even though I've logged in via SSH as myself, the main user, it places everything as root. It doesn't bother me enough to be ripping my hair out or anything, but it just doesn't feel "safe" to be constantly resetting permissions and ownership to 777.

Obsolete
Jun 1, 2000

chryst posted:

That doesn't sound right. If you're copying as a non-root user, the newly copied files should be owned by the person copying. Are you maybe using su without a - (dash) somewhere?

Rather than 777, remount the drives with "acl" as one of the options, and look up the commands for getfacl and setfacl. You can set NT-like permissions, and have fine-grained control over your files and directories.

One caveat for the ACLs is that tar won't save them, so restoring backups will lose then. (Look for an app called "star" to work around that)

Even when I download files with wget (without using sudo) when I'm logged in via SSH, the file defaults to being owned by root. I've gotten pretty used to the situation by now, as bizarre as it is, and I nearly always use a sudo command, but that just doesn't sound like that's the way it should be working. If it matters, my home partition, and the two mounted 400gb drives are all formatted as ext3, so there's no weird NTFS gibberish going on.

I've never used sudo with a dash before. I don't think I've ever even seen that before? I don't use "su," I always use "sudo." Any ideas? Thanks!

Obsolete
Jun 1, 2000

Nope. I get that when I download to my home directory, when I'm logged in as me. My two other drives are also chowned to me, and it happens there, too.

Edit: I haven't checked the setuid, I'll check that out.

Obsolete fucked around with this message at 01:32 on May 30, 2008

Obsolete
Jun 1, 2000

whoami returns as saying it's me, and id -a me returns:

code:
 
uid=1000(me)), gid=1000(me), groups=1000(me)
Isn't that what it's supposed to say?

Obsolete fucked around with this message at 04:30 on May 30, 2008

Obsolete
Jun 1, 2000

Harokey posted:

So you're not copying files over the network from another machine? I assumed you were because you said you were using it as a file server. I just want to make sure this is not the case, and you're just using this machine standalone.


Edit:
It may be useful to see the contents of /etc/fstab.

I do both. Files download (via rTorrent or some such) to one of the drives, then I copy those to the other drive into specific folders. However, even when using the machine standalone, and logged in as me, and downloading to my home directory, or copying something from my home directory to someplace else, I always have to either use sudo or chown the file to move the file to a drive outside my home directory, despite the drives all being chown'd, chgrp'd, and chmod'd to me.

Obsolete fucked around with this message at 19:37 on May 30, 2008

Obsolete
Jun 1, 2000

Lucien posted:

Please post your output of
code:
$ cat /etc/mtab
on the computer with the problem.

Done.

code:
/dev/sda1 / ext3 rw,relatime,errors=remount-ro 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
/sys /sys sysfs rw,noexec,nosuid,nodev 0 0
varrun /var/run tmpfs rw,noexec,nosuid,nodev,mode=0755 0 0
varlock /var/lock tmpfs rw,noexec,nosuid,nodev,mode=1777 0 0
udev /dev tmpfs rw,mode=0755 0 0
devshm /dev/shm tmpfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
lrm /lib/modules/2.6.24-17-generic/volatile tmpfs rw 0 0
/dev/sdb1 /media/sdb1 ext3 rw 0 0
/dev/sda3 /media/sda3 ext3 rw 0 0
gvfs-fuse-daemon /home/me/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=me 0 0
gvfs-fuse-daemon /root/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev 0 0

Obsolete
Jun 1, 2000

Harokey posted:

Wait, the drive or the drive's mount point? ie /dev/sdb1 or /media/sdb1

It sounds like you chowned /dev/sdb1 ?

Sorry, the mount point. So, /media/sda3 and /media/sdb1

Obsolete
Jun 1, 2000

I have a gigantic CSV file that uses pilcrow as the delimiter. I've tried to change it to tabs using tr and sed and can't seem to figure it out. It seems like the command doesn't recognize the pilcrow as a valid character, regardless if I'm using the symbol itself or hex code. I can't seem to hit on the right combination of characters that it wants me to use to run properly.

code:

tr '[pilcrow goes here]' '\t' < source.CSV > dest.csv

I've also tried with the $ in front of the first set but that didn't work either. I've tried both the character itself (u00b6) and some different hex combinations for it (\xb6, \xc2, etc).

Does tr not work with these non printable characters? I tried sed as well but don't think it will work.

Sorry if I didn't explain that very well. I've tried a bunch of different combos of characters and can't seem to hit on a solution.

Obsolete
Jun 1, 2000

so loving future posted:

I suspect it's your shell or terminal or some combination of horrible poo poo in there.

code:
$ tr '&#182;'  '\t' < source.csv           
foo		bar		bap
works for me?

err, sort of. There's something weird about the pilcrow that doubles it when tr'ing.

code:
$ tr -s '&#182;'  ',' < source.csv 
foo,bar,bap
and

code:
$ sed 's/&#182;/,/g' source.csv 
foo,bar,bap
work fine though

Huh. Well drat. I'll try a different shell and a different machine. Thanks for checking!

Adbot
ADBOT LOVES YOU

Obsolete
Jun 1, 2000

Mr Shiny Pants posted:

Me neither, and the original post did not show the character.

You learn something new every day.

I had to type the post on my phone so couldn't paste the character. It probably would have made the question easier!

That's interesting that people didn't know what that was called. I didn't even think about that part of it.

Thanks to the post about checking the encoding. I'll look into that too. I haven't had a chance to get back to it since I last posted. The encoding piece was really useful. Hopefully that or just changing shells solves the problem. Thanks again everyone!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply