Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #188979
| From | Thomas George <lists@tomgeorge.info> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Editing Problem with bash script and sed |
| Date | 2017-11-14 17:20 +0100 |
| Message-ID | <uLM6l-5Xj-1@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
The problem is editing long file names to shorten them. An example group of file names is attached. The bash script copied from BashScripting is attached. This script works perfectly with simple deletions, for example TrimLine.sh "College" "" will remove College from each line in File.txt. After experimenting with regular expressions with sed I found ls | sed -e s/S.*-// reduced the file names in File.txt to just the names of the Carols as shown in sed.txt. Used like this sed leaves the original file unchanged. Trim_Line.sh "S.*-" "" fails to actually change the file names. Assuming Trim_Line.sh does not accept the regex as a pattern, I edited it to replace the $1 in the sed command with the regex expression. This does not work, the original file is left unchanged. I also tried replacing $1 with ^.*- which also works with the test ls | sed -e s/^.*-// but still the file names are unchanged. I would appreciate any help or comments. Tom George
Back to linux.debian.user | Previous | Next — Next in thread | Find similar | Unroll thread
Editing Problem with bash script and sed Thomas George <lists@tomgeorge.info> - 2017-11-14 17:20 +0100
Re: Editing Problem with bash script and sed Roberto C. Sánchez <roberto@debian.org> - 2017-11-14 17:30 +0100
Re: Editing Problem with bash script and sed "Thomas Schmitt" <scdbackup@gmx.net> - 2017-11-14 19:30 +0100
Re: Editing Problem with bash script and sed "Thomas Schmitt" <scdbackup@gmx.net> - 2017-11-14 19:40 +0100
Re: Editing Problem with bash script and sed Greg Wooledge <wooledg@eeg.ccf.org> - 2017-11-14 19:50 +0100
Re: Editing Problem with bash script and sed Greg Wooledge <wooledg@eeg.ccf.org> - 2017-11-14 19:50 +0100
Re: Editing Problem with bash script and sed David Wright <deblis@lionunicorn.co.uk> - 2017-11-14 20:50 +0100
Re: Editing Problem with bash script and sed RESOLVED Thomas George <lists@tomgeorge.info> - 2017-11-14 21:20 +0100
Re: Editing Problem with bash script and sed Rusi Mody <rustompmody@gmail.com> - 2017-11-19 06:10 +0100
csiph-web