Reply
Thread Tools
peterleinchen's Avatar
Posts: 4,117 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#31
Originally Posted by misterc View Post
EDIT: well, the whole line searches for fdisk and replaces it with fsck and g does that
Well, after just finishing a well constructed sed command
$(echo $name | sed "s/(operator.)/( `echo $oper | sed 's/\(&\)/\\\&/'` )/")
for replacing some chars, I thought s/re/replace/ would be enough? It is for sed.
But ed (and vi) take s/re/replace/ to just replace in that specific line!?
And s/re/replace/g replaces globally (all text lines)?
 

The Following User Says Thank You to peterleinchen For This Useful Post:
Copernicus's Avatar
Posts: 1,986 | Thanked: 7,698 times | Joined on Dec 2010 @ Dayton, Ohio
#32
Originally Posted by peterleinchen View Post
Well, after just finishing a well constructed sed command
$(echo $name | sed "s/(operator.)/( `echo $oper | sed 's/\(&\)/\\\&/'` )/")
for replacing some chars, I thought s/re/replace/ would be enough? It is for sed.
But ed (and vi) take s/re/replace/ to just replace in that specific line!?
And s/re/replace/g replaces globally (all text lines)?
I should probably just look this up, but off the top of my head: "ed" is a single-line text editor. "vi" is a full-screen text editor based more or less off of "ed", and therefore has line-oriented commands similar to ed.

The "s" command is for search-and-replace. The "s/searchitem/replaceitem" will look for the regular expression "searchitem" and replace it with the regular expression "replaceitem" (at least I think they are regular expressions) in the current line of text. You can add a third slash to provide extra options; the "g" option stands for something like "global", which means to replace every instance of "searchitem" with "replaceitem" in the current line of text. This form of the command should work with both ed and vi.

Since vi is a multi-line editor, it has additional prefix options to specify ranges of lines. (At least, I don't recall these being used in ed.) So, if you want to do a search and replace on every line, you can use the "%" prefix:

%s/searchitem/replaceitem

But that only catches the first instance of searchitem on each line; you still have to add the g if you want to replace every instance on every line:

%s/searchitem/replaceitem/g

You can specifically control the begin and end of a range using two line identifiers separated by a comma. So, to search and replace from lines 5 to 10, do:

5,10s/searchitem/replaceitem/g

If you want to search and replace from the current line to the end of the file, "." means current line, and "$" means end of file:

.,$s/searchitem/replaceitem/g

You can even use the result of a search to define a line. I'll often put a string like "mymark" on the line I want a search and replace to end, move the cursor where I want it to start, and use:

.,/mymark/s/searchitem/replaceitem/g

Anyway, you can do lots of different fun tricks with this system.
 

The Following 3 Users Say Thank You to Copernicus For This Useful Post:
Posts: 391 | Thanked: 908 times | Joined on Aug 2011 @ suncity
#33
Originally Posted by michaaa62 View Post
And right you are!
It is the backup of the first sector of the partition, which should be copied with dd on low level.
I edited the above post.
Hi All!

I just wanted to say thank you, because today some USB mass storaging went wrong with Win XP and all the MyDocs was gone. I did the dd command, but it didn't work.
BUT! I attached my phone (without reflashing or anything!!!) mass storage mode to my Win XP then opened the command prompt and typed: "Chkdsk /F E:\" (E was the label of the MyDocs partition; it saw the partition but said it is unaccessible). This did the trick, my partition is (almost) fully back again. Only some video files gone from .videos folder. But thats it.

I just wanted you to know.

Cheers,

jm
 

The Following 2 Users Say Thank You to justmemory For This Useful Post:
Posts: 1,994 | Thanked: 3,342 times | Joined on Jun 2010 @ N900: Battery low. N950: torx 4 re-used once and fine; SIM port torn apart
#34
Originally Posted by stlpaul View Post
I think maybe you should use /usr/sbin/mmc-mount instead of mount, that way it applies all of the proper mounting options.
Quick reply...

Thank you! I have tried, as you said:

/usr/sbin/mmc-mount /dev/mmcblk0p1

It has started fsck -a on the filesystem.

I have known the partition to be problematic, but mmc-mount was my panic-resort, since today the device plain out refused to mount MyDocs - even as read-only filesystem.

I dislike fsck.vfat for not being able to compare and repair both halves (for me, fsck says that "FATs appear to be intact, but are not identical" and chooses _one of two_ to 'check-repair'). Since fsck intends to truncate some of the files to 0 (Cluster chain, something), I plainly regarded it as not competent enough to repair filesystem without deleting the 'problematic' files. However, it's better to lose 'problematic' files (as it will likely happen with -a switch) than to have no access to the filesystem whatsoever.

Hopefully, after several runs of mmc-mount (one run is too long for one battery; several batteries help) the file-system will be mounted.

Best wishes.
 

The Following 2 Users Say Thank You to Wikiwide For This Useful Post:
Posts: 1,994 | Thanked: 3,342 times | Joined on Jun 2010 @ N900: Battery low. N950: torx 4 re-used once and fine; SIM port torn apart
#35
Quick clarification...

I have actually confused the switches. "-a" does not solve the problem; I have already used it before, several times, along with "-v", "-l", and even "-t". "-w" did solve the problem, at expense of deleting-removing-destroying any files which could be at fault. It's probably just because fsck does not run through whole MyDocs filesystem before the battery gets drained.

Best wishes.
~~~~~~~~~~~~~~~~~
Per aspera ad astra...
 

The Following User Says Thank You to Wikiwide For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 01:24.