Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How do you preserve the max length of a line after replacing a specific value? Post 303041345 by asdfghjkl on Thursday 21st of November 2019 02:44:43 PM
Old 11-21-2019
How do you preserve the max length of a line after replacing a specific value?

I'm new with scripting and I can't seem to figure out what I should do to get the output that I want.

My file content would be below.
Code:
ID2|ID3       |ID4|ID5       |

I'm trying to replace the field of ID3 which has a fixed length of 10 characters, for each entry I have placed on a .txt file and placing the value on variable called "NEW".

Here is my sed command.
Code:
sed -i 's/ID3/$NEW/g' TESTFILE_TEST

Is there anyway to maintain the 10 characters on the field for each entry it reads on my .txt file?

Last edited by Scrutinizer; 11-22-2019 at 05:00 AM.. Reason: code tags please
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Length of a Unix filepath max length

Hi Guys, Could anyone shed some light on the length of a Unix filepath max length pls ? thanks ! Wilson (3 Replies)
Discussion started by: wilsontan
3 Replies

2. Shell Programming and Scripting

what is the max length of args i can pass in shell?

i have a shell script which takes several args. what is the maximum length of string i can give as argument? (6 Replies)
Discussion started by: senthilk615
6 Replies

3. Shell Programming and Scripting

Counting the max length of string

Hi all, I have a flat file of 1000 rows. I want to check the length of the 5th column. The one having the longest length , I want to set it as DEFINED PARAMETER. So later I can check others with that particular number only. Any ideas ?? (2 Replies)
Discussion started by: ganesh123
2 Replies

4. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

5. UNIX for Dummies Questions & Answers

replacing string in a column on a specific line

hi, i currently have a file with columns similar to this customer name owed CID123 John 300 CID342 harry 500 at present i use use awk to find the amount owed by the customer using the customer ID (CID). if the customer spends more money how would i go about using sed/awk etc to... (2 Replies)
Discussion started by: skinnygav
2 Replies

6. Shell Programming and Scripting

replacing field in specific line in a file

Hi, I know there are lots of threads on replacing text within files, usually using sed or awk. However, I find it hard to adapt examples that I found to my specific case. I am kind of new to UNIX and have hard times learning the syntax either for sed or awk so I would appreciate any help. Here's... (5 Replies)
Discussion started by: vytenis
5 Replies

7. UNIX for Advanced & Expert Users

How to increase max username length?

Hi, This is my first post to this site. So kindly forgive if I am writing in a wrong section. My query is that... I want to modify the max username length size. I guess it is 32/64 on CentOS. Now I want to change it to 128. Is there any way to do that? Thanks in advance!! :) (4 Replies)
Discussion started by: ajay303
4 Replies

8. UNIX for Dummies Questions & Answers

Modify the max username length

Hey Any one... Do u know any way I can modify the max username length in unix? I guess it is 32/64 characters by default. Suppose I want to increase it to 128. i hav tried /etc/skel but no use... How can I do that? (2 Replies)
Discussion started by: MayureshRisbud
2 Replies

9. Shell Programming and Scripting

SED Replacing all but one regex match on a line or specific matches

Hi, I'm attempting to rename some files that have spaces in them. Without linking sed commands together is it possible to replace the first three "." to " ". File.name.is.long.ext -> File name is long.ext I can get the desired effect with echo "File.name.is.long.ext" | sed 's/\./ /g;s/... (5 Replies)
Discussion started by: vectox
5 Replies

10. Shell Programming and Scripting

Find max length of the field and then replace zero

hai guys, pick the 1st field and calculate max length. if suppose max length is 2, then compare the all records if <2 then add zero's prefix of the record. for ex: s.no,sname 1,djud 37,jtuhe in this max length of the 1st field is 2 right the output wil be s.no,sname 01,djud... (6 Replies)
Discussion started by: Suneelbabu.etl
6 Replies
ID3REN(1)						      General Commands Manual							 ID3REN(1)

NAME
id3ren - Reads and writes ID3 tags from mp3 files. SYNOPSIS
id3ren [-help] [-song=SONG_NAME] [-artist=ARTIST_NAME] [-album=ALBUM_NAME] [-year=YEAR] [-genre={# | GENRE}] [-comment=COMMENT] [-track=TRACK] [-showgen] [-searchgen={# | GENRE}] [-default=DEFAULT] [-copytagfrom=FILE [-copysong] [-copyartist] [-copyalbum] [-copyyear] [-copygenre] [-copycomment] [-copytrack] [-copyall] ] [-quick] [-noalbum] [-nocomment] [-noyear] [-nogenre] [-notrack] [-tag] [-edit] [-notagprompt | -showtag | -striptag | -tagonly] [-nocfg] [-log] [-quiet] [-verbose] [-defcase | -lower | -upper] [-remchar=CHARS] [-repchar=CHARS] [-space=STRING] [-tagfromfilename | -tagffn] [-tagtemplate=TAGTEMPLATE] [-template=TEMPLATE] [FILE1 FILE2.. | WILDCARDS] COPYRIGHT
id3 Renamer (C) Copyright 1998 by Robert Alto (badcrc@tscnet.com) (C) Copyright 2001 Christophe Bothamy (cbothamy@free.fr) DESCRIPTION
id3ren is used to rename batches of mp3 files by reading the ID3 tag at the end of the file which contains the song name, artist, album, year, and a comment. The secondary function of id3ren is a tagger, which can create, modify, or remove ID3 tags. OPTIONS -album ALBUM_NAME Sets the album name to use when tagging files. All files will be tagged with this album name without prompting. -album=ALBUM_NAME Sets the album name to use when tagging files. All files will be tagged with this album name without prompting. -artist=ARTIST_NAME Sets the artist name to use when tagging files. All files will be tagged with this artist name without prompting. -comment=COMMENT Sets the comment to use when tagging files. All files will be tagged with this comment without prompting. -copyalbum Copies the album field from the source file tag set by -copytagfrom -copyall Copies all the fields from the source file tag set by -copytagfrom -copyartist Copies the artist field from the source file tag set by -copytagfrom -copycomment Copies the comment field from the source file tag set by -copytagfrom -copygenre Copies the genre field from the source file tag set by -copytagfrom -copysong Copies the song field from the source file tag set by -copytagfrom -copytagfrom=FILE Sets the filename to copy tag field from. -copytrack Copies the track field from the source file tag set by -copytagfrom -copyyear Copies the year field from the source file tag set by -copytagfrom -defcase Use the default case of characters from the ID3 tag when renaming files. This is default. -default=DEFAULT Sets the default field to be used only when renaming if a field is blank. Useful when renaming and creating "unknown" subdirecto- ries. Defaults to "unknown". -edit If a file already has a tag and you want to change just one specific field of the tag, use this option in conjunction with -tag and the option for the field you want to change. For example to change just the album name of a file: id3ren -tag -edit -album="New Album Name" sample.mp3 * This option is a toggle. -genre=# | GENRE_NAME Sets the genre to use when tagging files. All files will be tagged with this genre without prompting. To see a list of allowable genres use the -showgen argument. -genre accepts either the number of the genre as displayed with -showgen, or the name of the genre. -help Displays the help screen. -log Log most output to id3ren.log. * This option is a toggle. -lower Convert file names to lowercase characters. -noalbum Don't prompt for the album when adding a tag. * This option is a toggle. -nocfg Don't try reading any config files, even if they exist. * This option is a toggle. -nocomment Don't prompt for a comment when adding a tag. * This option is a toggle. -nogenre Don't prompt for a genre when adding a tag. * This option is a toggle. -notagprompt Never prompt for tag information. Files without tags are skipped. * This option is a toggle. -notrack Don't prompt for the track number when adding a tag. * This option is a toggle. -noyear Don't prompt for the year when adding a tag. * This option is a toggle. -quick Automatically sets -noalbum, -nocomment, and -noyear. -quiet Run quietly, displaying only errors or prompts. * This option is a toggle. -remchar=CHARS CHARS indicates a string of characters that will be removed from the filename if found. -repchar=CHARS CHARS indicates a string of characters, EACH followed by the character to replace it with. For example, to replace all plus '+' signs with a hyphen all '&' with '_', you would use '-repchar +-&_'. -searchgen=# | GENRE Searches the list of genres and displays either the genre name corresponding to #, or shows all substring matches of GENRE. -showgen Displays all the music genres currently in the program. -showtag Display the tags for the specified files. No renaming is performed. -song=SONG_NAME Sets the song name to use when tagging files. All files will be tagged with this song name without prompting. -space=PSTRING Change all spaces in the renamed file to STRING. To remove all spaces, use -striptag Remove the tags for the specified files. * This option is a toggle. -tag Always ask for a tag, even if the file already has one. * This option is a toggle. -tagfromfilename, -tagffn Use informations from the filename when tagging. See tagtemplate. * This option is a toggle. -tagonly Don't rename any files, just ask for tag information. Note that -tagonly only asks for tag information on files that don't have a tag already. To have it ask for a tag on all files, use with -tag. * This option is a toggle. -tagtemplate=TEMPLATE Use TEMPLATE as the basis for tagging files. The default template used is '[%a]-[%s].mp3'. Identifiers that can be used in the template are: %a - Artist name %c - Comment %s - Song name %t - Album title %n - Track Number %y - Year %g - Genre %d - Dummy It is a VERY good idea to have fixed separators between fields. -template=TEMPLATE Use TEMPLATE as the basis for renaming files. The default template used is '[%a]-[%s].mp3'. Identifiers that can be used in the template are: %a - Artist name %c - Comment %s - Song name %t - Album title %n - Track Number %y - Year %g - Genre -track=TRACK Sets the track number to use when tagging files. All files will be tagged with this track number without prompting. TRACK must be an integer between 1 and 99. -upper Convert file names to uppercase characters. -verbose Display more messages than usual. * This option is a toggle. -year=YEAR Sets the year to use when tagging files. All files will be tagged with this year without prompting. And of course the program accepts wildcards for filenames. FILES
*.mp3 All your mp3 files SEE ALSO
lame(1), xmms(1), mpg123(1), mp3blaster(1) BOGUS
If you have questions, comments, or bug reports, please contact cbothamy@free.fr To get the latest version, please visit http://cboth- amy.free.fr/projects/id3ren/ 14 july 2001 ID3REN(1)
All times are GMT -4. The time now is 11:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy