General :: Remove Extra Characters From Multiple Files
Sep 18, 2011
I have a directory (Linux user) with a number of files which contain an added [!] to the end of each file name so that each file reads out as:
foo something [!].zip
bar something [!].zip
helloworld [!].zip
etc.
What is the quickest way to batch rename these to remove the ending [!] character combination from these file names?
View 2 Replies
ADVERTISEMENT
Feb 12, 2010
I have a folder with various subfolders of files. These files all have two extra characters on the end that I want to get rid of. How would I go about telling the terminal to go into X directory and every subdirectory of X directory, look for all files with the extra characters, remove them, and keep everything else the same?
View 3 Replies
View Related
Aug 3, 2011
sed '/
$/ {N s/
//}'
sed: -e expression #1, char 10: extra characters after command
I want to understand what is wrong with my command line. When I can do the some of following in a script but not in a command line. I have been working through the tutorial at [URL]. When I got stuck at the section Working with Multiple Lines. These script works fine.
#!/bin/sh
sed '
# look for a "#" at the end of the line
/#$/ {
# Found one - now read in the next line
N
# delete the "#" and the new line character,
s/#
//
}' file
In my case I am looking for or return ^M.
#!/bin/sh
sed '
# look for a "#" at the end of the line
/
$/ {
# Found one - now read in the next line
N
# delete the "#" and the new line character,
s/
//
}' file
The problem is when I try to convert it to a single line shell command it gives me an errors.
sed '/
$/ {N s/
//}'
sed: -e expression #1, char 10: extra characters after command
sed '/
$/{N s/
//}'
sed: -e expression #1, char 9: extra characters after command
sed '/
$/{Ns/
//}'
sed: -e expression #1, char 8: extra characters after command
I want to understand what is wrong with my command line. When I can do the following in a script but not in a command line. I have created a sed script to do the work I want.
cat test.sed
#!/bin/sed -f
/
$/ {
N
s/
//
}
View 1 Replies
View Related
Jan 13, 2010
I was doing some data recovery with Photorec and by the time I was done I have over 700 folders (recup_dir.).The only solution I was able to apply was the one posted by pljvaldez on this site dated 04-09-08, 09:01 AM. After doing the same thing for at least 70 times I decided to ask, so, is there anyone that knows how to delete multiple folders at the same time.
View 2 Replies
View Related
Apr 27, 2010
I hope you can help. I have a collection of spreadsheets with data that needs to be imported in to SQL. The data has been manually entered although there are portions where data has been copied and pasted from the web.
When converting these sheets to a CSV I get strange characters where it looks as though data has been copied and pasted. Is it possible to write a script (AWK?) to pull out these characters?
I guess the script will need to keep alpha characters, spaces, numerics and commas but nothing else. How easy is this to do?
View 7 Replies
View Related
Aug 26, 2009
Below is extract of my file:
What I need is to replace "--destination-path=" with "--destination-path=/home/dest"
i.e. desired output is ----destination-path=/home/dest
I could achieve it with below command
$cat outgoing-xfer|grep destination-path|perl -pi -e "s/destination-path=/destination-path=/home/dest/g"
But the problem is that in this case i just wanted to append "/home/dest" for which I could easily escape "/" with just two "", but I wonder if i have a long path like "/a/b/c/d/e/f/g/h/i/j" I will have to escape so many /. Is there any other way by which I can avoid escaping forward slash.
I tried following:
But receiving follo error
Bareword found where operator expected at -e line 1, near "s/destination-path=/'destination-path=/home"
syntax error at -e line 1, near "s/destination-path=/'destination-path=/home"
Bad name after dest' at -e line 1. tried with enclosing in double quotes as well but in vain
View 5 Replies
View Related
May 13, 2011
My server was hit with an injection script which has placed code across many of my clients files. I need a script that can remove a block of php code that spans multiple lines, multiple directories/files and is dynamic, meaning that part of the code changes. I think using find/sed is what I need but cannot seem to figure out how to get it to work.The following is the script that is being injected everywhere. The catch is that they have generated dynamic code at the start/end of the script. (I have commented the parts that are dynamically changing on EVERY instance).PLEASE NOTE: Directly following this script is the start of a valid php script that I do not want to delete.
<?php
//{{65281980 - DYNAMIC!!
GLOBAL $alreadyxxx;
[code]...
View 2 Replies
View Related
Jun 5, 2009
I want to remove duplicate or multiple similar lines from multiple files. I.e. if I have four files file1.txt file2.txt file3.txt and file4.txt and would like to find and remove similar lines from all these files keeping only one line from these similar lines. I only that uniq can be used to remove similar lines from a sorted file.
View 9 Replies
View Related
Aug 23, 2010
I am to rename all the files within a directory (which contains multiple subdirectories) recursively without invalid characters.
I tried the coding posted above.
find . -type f -printf '%p
' | while read file; do
oldfile=$(basename "$file")
newfile=$(echo "$oldfile" | sed 's/[^A-Za-z0-9_.]/_/g')
if [ ! "$newfile" == "$oldfile" ]; then
echo mv "$file" "${file%$oldfile}$newfile"
code....
but I get an error on both of them stating "find: bad option -printf find: [-H | -L] path-list predicate-list"
View 9 Replies
View Related
Apr 19, 2010
I'd like to know how to leave only tty1 and 2 and permanently disable others. (I'm running Lenny/i386).
View 4 Replies
View Related
Jul 15, 2010
I'm trying to search through some pdf files and I'm doing so by converting them to text files using pdftotext which is fine but I'm trying to get the number of occurrences in a paragraph of different words and it's adding a new line character at what it thinks is the right hand margin. I'm trying to remove all these singe new line characters but keep the doubles and I can't seem to work it out. i.e.
This is some text that has been broken.
Another paragraph.
becomes
This is some text that has been broken.
Another paragraph
View 9 Replies
View Related
Jun 1, 2010
I want to archive all .ctl files in a folder, recursively.tar -cf ctlfiles.tar `find /home/db -name "*.ctl" -print`The error message :tar: Removing leading `/' from member namestar: /home/db/dunn/j: Cannot stat: No such file or directorytar: 74.ctl: Cannot stat:No such file or directoryI have these files: /home/db/dunn/j 74.ctl and j 75. Notice the extra space. What if the files have other special characters? How do I archive these files recursively?
View 2 Replies
View Related
Jan 1, 2010
How do I remove the extra Kernels from my boot menu as listed below?
View 3 Replies
View Related
May 9, 2010
Take a look at the "screen shot attachment" you will notice that I have multiple listings for the HD - WIN_XP, WIN_7 and GAMES. I was checking out both NTFS CONFIGURATION TOOL and MOUNTMANAGER. I Removed MOUNTMANAGER but the multiple listings remain? I would like to have the ability to Mount and Unmount any drive from the File Manager except ARCHIVE this drive I need to mount as Ubuntu Boots up.
keivn@kj-desktop:~$ sudo fdisk -l
Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
[code]....
View 6 Replies
View Related
Jun 6, 2010
I'm running Ubuntu 9.10 dual booted with Windows XP. Ever since I installed 9.10, I get a long list of OS's (actually, multiple repeats of what appears to be the same Ubuntu install), and I can't get rid of them.I've looked through various tutorials and the GRUB 2 Community documentation (https://help.ubuntu.com/community/Grub2) but I still can't get rid of the menu items.I edited the 40_custom file and was able to add the entries I wanted to see, and then chmoded 644 all the other files in the /etc/grub.d directory and run update-grub.The custom entries do appear at the end of the menu now, but the old entries are still there as well. This is what I get when I run the update-grub:
Code:
yoodle@HANSOLO:/etc/grub.d$ sudo update-grub
Searching for GRUB installation directory ... found: /boot/grub
[code]....
View 2 Replies
View Related
Feb 15, 2010
I am dragging my files over to a new Fedora 12 installation and I just noticed that special characters are not taken into account when sorting files by name (I want '_js' to come before 'images').Is there a way to make the sorting process behave like Windows, where files starting with a special character are listed first?
View 5 Replies
View Related
Dec 13, 2010
file = TT.ParlayX_RequestLog_78653_20101212180044.log.17490
1. Want to remove the characters before the first dot (.) including the dot (.)
2. Want to remove the characters after the last dot (.) including the dot (.)
That is, basically, I want the output as:
ParlayX_RequestLog_78653_20101212180044.log
View 7 Replies
View Related
May 12, 2010
I have a txt file with couple of comment lines:
Number of title = !num!
#line1
#line2
#line3
I wrote a script with "sed" to replace !num! in this file, which is very straightforward. However, based on the !num!, I want to remove the number of "#" based on the !num! value. Is there an easy way to do that with "sed"; otherwise, i will have to write a script to loop through the file.
View 8 Replies
View Related
Mar 15, 2010
I have hundreds of directories in various subdirs that I need to remove. I want to remove all of these dirs, but can only find solutions on how to do remove files (or how to remove subdirs from within the current dir).
I think I need something like
find -iname 'testfile*' | xargs rm -i
where I want to remove every directory that contains the word 'testfile' within the directory name. I know xargs wont work for dirs,
View 9 Replies
View Related
Aug 28, 2011
While modifying the definition of my PS1, I saw that "[" and "]" markers should be added to help bash to compute the right display lenght. Many exemples on the web do not use them or even mention them.I searched for a solution to add them automatically, like with sed, but I didn't find any example.Are they still needed and is there a recommandation not to use sed to define PS1?
View 1 Replies
View Related
Feb 20, 2011
I am doing a mysql query with a bash shell script like:
mysql translator -u root --password=******** -e "SELECT word FROM tagalog ORDER BY RAND() LIMIT 1" | while read line; do
echo $line
So when I echo the value of $line I get:
word
magandang umaga
"word" is the name of the row in the table and maganda umaga is a randomly selected choice from the row. Is there a way i can remove the name of the row from the variable $line. With a result that will allow me to echo $line and output only the randomly selected entry in from the row e.g. magandang umaga
View 13 Replies
View Related
Jun 3, 2010
I'm having a bit of a headbanger trying to work this one out. I'm trying to remove all of the characters on a line apart from the last 17. For example, I need to change this:
Code:
00000000000000000089;0bbfaeb8
01000000000000000089;0bcb5948
00000000000000000089;0bcc4c40
[code]....
View 5 Replies
View Related
Aug 25, 2009
How can you create a script to move or copy files from a main directory into multiple directories below the main directory.
View 7 Replies
View Related
Jan 23, 2010
I want to be able to remove the first character of a line when I highlight multiple lines in gedit. Example:
%Example is
%Commented Code
%Uncomment using this shortcut
I would then highlight/select these lines, and remove the first character to make it look like this:
Example is
Commented Code
Uncomment using this shortcut
I'm pretty sure there is an actual shortcut for this. If there is another text editor on Linux that it would work in, it would be nice to know how to do it in that editor as well.
View 2 Replies
View Related
Nov 7, 2010
I am using 'sed -e /foo/d' to match lines which I want to delete from a file. I discovered I have some lines which contain random (extended?) characters like 'ủ' which I would also like to delete. The lines in the file should only contain alpha numeric characters.
View 8 Replies
View Related
Apr 14, 2010
How can I remove characters from grep output using sed? code...
View 9 Replies
View Related
Jan 30, 2011
I am reading strings from a file using readline() function,the file contains some strings which has only special characters, I need to avoid the strings which has only special characters, the special characters are not similar. How to do it in python.??
View 2 Replies
View Related
Jul 26, 2010
I am working with a Tcl script and have some strings in the following format (RE):
[a-zA-Z]+[0-9]{6}-[0-9]
There are some leading letters, combinations of capital and lowercase. Then six digits, followed by a hyphen, then one more digit. I would like to remove all of the leading alphabetic characters from the string. The resulting string would then be in this format: [0-9]{6}-[0-9]. In other words, six numeric digits, a hyphen, then one more digit.
I have tried:
Code:
set newstr [string trimleft $origstr alpha]
But that only removes the first alphabetic character, not all of them.
I couldn't get anything with regsub to work correctly, but I am somewhat of a noob with RE's in general and regsub in particular. There are usually 5 leading letters at the beginning of these strings, and I could in most cases get away with using string replace and constant indices to extract the substring. However, my preference is for this to be robust enough to handle all cases with 1 through n leading alphabetic characters.
View 3 Replies
View Related
Jun 10, 2009
I quit using Fedora when FC4 came out, but I decided to switch back now that F11 has come out. I'm liking everything so far, though it is different from what I became used to (Ubuntu). My main question so far has to do with language support, and I cannot seem to find an answer anywhere for this. I need to have language support for several languages (including support to enter complex characters) for all applications for which it they are available. How do I install all the language files at once for, say, Korean, rather than installing each library one by one?
View 6 Replies
View Related
Jan 18, 2010
How do you perform a long directory listing of all files in the /bin directory that have exactly three characters in their name?
View 1 Replies
View Related