Adding semicolons


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding semicolons
# 1  
Old 10-25-2010
Adding semicolons

Lets say I wanted to add a ; before the last 6 characters of my variable how would I do this?
# 2  
Old 10-25-2010
Code:
$ v=abcdefghy
$ echo "${v%??????};${v#${v%??????}}"
abc;defghy

# 3  
Old 10-25-2010
Or
Code:
$ v=abcdefghy
$ echo "${v:0:${#v}-6};${v:${#v}-6}"
abc;defghy

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies

2. Shell Programming and Scripting

Printing paragraph between semicolons having XXXX

Hello experts, I have below file: 1 2 3 4 5 6 ; 7 8 9 10 XXXX 1 ; 2 3 (4 Replies)
Discussion started by: manuswami
4 Replies

3. UNIX for Dummies Questions & Answers

Problems removing files with semicolons in the filename

There are some 40 files created by accident with filenames with semicolons, as well as other non-printable characters. I can not find a correct way to delete them. This is what I tried: bash-2.03# ls bad|head -1 000025;001;1377795616; bash-2.03# rm "bad/000025;001;1377795616;???" rm:... (17 Replies)
Discussion started by: migurus
17 Replies

4. UNIX for Dummies Questions & Answers

Adding

my shell script: #!/bin/ksh date +%d > /tmp/day.log day=`tail /tmp/day.log` ############################ for example: date +%d shows me 05 i want to add 14 days to 05 into my above script. bc 5+15 19 but i am not sure how to put into above script. (5 Replies)
Discussion started by: lawsongeek
5 Replies

5. Shell Programming and Scripting

Replace semicolons with tabulators, new lines are disappearing

Hi Gurus! Example file: 1;AAA;BBB 2;CCC;DDD We want to replace semicolons to tabulators. Like this: 1 AAA BBB 2 CCC DDD We have tried these codes. With PERL: #!/bin/bash for i in `find /folder1/ -name "*.CSV"` do bi="`basename $i awk -F"." {'print $1'}`" cat... (2 Replies)
Discussion started by: JanneN
2 Replies

6. UNIX for Dummies Questions & Answers

2 semicolons

Just wondering what 2 semicolons together after a command means (2 Replies)
Discussion started by: millsy5
2 Replies

7. Shell Programming and Scripting

Removal of last-semicolons in line with sed

Hello, I'm trying to remove an arbitrary number of semicolons at the end of each line in the input file. Input: 44;I;1000031;;;B;0137;0;;01.02.2008;03.02.2009;;;;;;;;;;;;;0028-101746;;; 45;I;1000031;;;B;0137;0;;01.02.2008;03.02.2009;;;;;;;;;;;;;0028-101746;;;;; ... (6 Replies)
Discussion started by: uioreanu
6 Replies

8. Shell Programming and Scripting

Searching for a pattern between 2 semicolons

I have logs which is having strings like below, errorMsg;; errorMsg;bad input; so I need to grep from logs file which searches for errorMsg followed by semicolon followed by any text and then ending again with semicolon. More importantly, I should not get errorMsg and having nothing... (4 Replies)
Discussion started by: gopikrish81
4 Replies

9. Shell Programming and Scripting

Adding new lines to a file + adding suffix to a pattern

I need some help with adding lines to file and substitute a pattern. Ok I have a file: #cat names.txt name: John Doe stationed: 1 name: Michael Sweets stationed: 41 . . . And would like to change it to: name: John Doe employed permanently stationed: 1-office (7 Replies)
Discussion started by: hemo21
7 Replies

10. UNIX for Advanced & Expert Users

adding zero's

Hi I am comparing two files, 100th column have formatting issue i mean 1 file have scale 4 and anothe file scale 2 ,if scale 2 need to add two zeros.Please any idea how to add two zers to 100th coulmn if scale is 2 file 1 .................1234.2000 file2 ................1234.20 ... (3 Replies)
Discussion started by: mohan705
3 Replies
Login or Register to Ask a Question