remove characters from list of files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers remove characters from list of files
# 1  
Old 01-30-2011
remove characters from list of files

done some homework on this--
after i remove up to and including the ) i want to take newfile.txt and use that list to remove the files from a file in my the directory pwd
i have a input.txt file
cat input,txt
1)mary.jpg
12)john.jpg
100)frankkfkdf .jpg
i want to remove the characters in the beginning of the line example only up and including the )
some thing like cut -c (2-35 ) < input.txt--i assume it would return> newfile.txt
i don't know the length of the file name but it is less than 35 characters and of different lengths

newfile.txt

cat newfile,txt
ry,jpg
hn.jpg
ankkfkdf.jpg

then xargs rm < newfile.txt
here goes my example and can it be done like this
cut -c (2-35) <inputfile.txt > newfile.txt
then
xargs rm <newfile.txt--here i know is where the problem is for me
the directory or should i say file is called all_images
cat all_images
dfdfdf.jpg
dfd.jpg
is this the code

xargs all_images rm < newfile.txt

i hope this is clear
take a list of file names and remove up to and include the )
take this list of file names and delete these files from another file all_images

i really appreciate all your help
i know there are other ways to do this with spreadsheets or use sed ( really unfamilar with it but doing homework)
but unix you know is really KooL and i love working with it
peter
# 2  
Old 01-30-2011
Hi,

It's difficult for me to understand your problem. Let me explain it to check if I'm correct:

First of all you want to read file names of 'input.txt' without all characters until the first ')'.

The second part is less clear for me, for each file read of 'input.txt, go to '~/all_images/' and remove them?, or all_images is a plain text file and you want modify that file to remove entries also found in 'input.txt??

Thanks,

Regards,
Birei
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting | Return list of unique characters in files

Hi, I am trying to script the below, but I am not very good at it :( Your help would be greatly appreciated. 1. read all files in the directory in strings strings *.* 2. in each file, for each line that contains "ABCD", store characters located at position 521 and 522 of this line... (9 Replies)
Discussion started by: clippertm
9 Replies

2. Linux

Remove matching files from a list

hi, i have a cache file with below file list more gtda_11.cache GTDA_Dly_Pmix_GB_6_20130624.20130624070610.psv GTDA_Dly_Pmix_CH_006_20130624.20130624140018.psv GTDA_Dly_Pmix_GB_6_20130624.20130624070620.psv GTDA_Dly_Pmix_BE_6_20130624.20130624070620.psv... (2 Replies)
Discussion started by: renuk
2 Replies

3. Shell Programming and Scripting

Remove duplicates from two files using n characters for comparison

Hi All, I have two files file1 123456CRTGHG 125437CRNDGF 126537CRDDGF file2 123456CRTZHC 124567CJHGHG 125987CJHGDF I need to compare the two files and any records in file 1 and 2 based on initial n characters (6 in example) need to be ignored. string separated by unprintable... (2 Replies)
Discussion started by: Bruble
2 Replies

4. Shell Programming and Scripting

Remove first row in a list of files

Hi I want to remove the first row in a list of files and am trying to do via the following. I've tried various quotes to redirect the modifed file to a newly named version of itself but no joy. Can you help? > for i in 'ls A*'; do sed '1d' $i > $i"_complete"; done bash: $i"_complete":... (4 Replies)
Discussion started by: ksexton
4 Replies

5. UNIX for Dummies Questions & Answers

How to remove characters from multiple .txt files

Friends, I want to remove charecters from multiple .txt files. Foe example : In this .txt files there are many "ctrl m" present in last of each line in one .txt file. I want to remove "ctrl m" from each line from all .txt files. Need your help regarding this. (4 Replies)
Discussion started by: meetsubhas
4 Replies

6. Shell Programming and Scripting

Help to find string and return following characters from list of files

Hi, I'm fairly new to UNIX, but hopefully some-one can help me with this: I am using the following code to find files with the name "example.xml": find . -name "example.xml" -print that would print me a list like the example here: ./dir1/dir2/example.xml... (5 Replies)
Discussion started by: boijie
5 Replies

7. UNIX for Dummies Questions & Answers

Files with special characters - how to remove

Hi, I have a directory that has a file which contained special characters in the filename. Can someone please advise how to remove the file, preferably with a rm -i ? Thanks in advance. Listing is as below: {oracle}> ls -1b bplog.bkup.001 bplog.bkup.002 bplog.bkup.003 bplog.bkup.004... (1 Reply)
Discussion started by: newbie_01
1 Replies

8. UNIX for Advanced & Expert Users

Can't list or remove files from a directory

Hi I have a problem. One of the directories in /var, on one of my servers, has filled up with loads of files. I have tried to list the directory to see what is in it, but the 'ls' command just hangs. Same thing happens when I try to use 'rm' to remove files from that directory. I can see what... (2 Replies)
Discussion started by: m_smith
2 Replies

9. Shell Programming and Scripting

How to Remove Ctrl M characters in files from directories and its subdirectories

Hi, How to recursively remove Ctrl M characters in files from a directory and its sub directory ? I know unix2dos command is there but to remove in bunch of files ... ? Thanks (7 Replies)
Discussion started by: skdp
7 Replies

10. UNIX for Dummies Questions & Answers

Too many files to list / remove

I have a directory which has 614,000 files. When attempting to do an ls -ralt in the directory an error too many arguments is shown. 1. I would like to see what files and their stats in the directory 2. I would like to delete certain files of a certain age (3 Replies)
Discussion started by: dinplant
3 Replies
Login or Register to Ask a Question