UNIX BASH replace char with dash w/o SED


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers UNIX BASH replace char with dash w/o SED
# 8  
Old 10-05-2011
Thanks for sharing!
# 9  
Old 10-05-2011
Quote:
Originally Posted by gary_w
I started messing around with a hangman game too for the fun of it after reading a posting here somewhere by Corona688 that gave an example on manipulating strings.
May I suggest you use anything other than the dash shell? maybe bash or ksh -- even busybox ash is better.

I also don't understand why you put BASH in the title when you don't have it. Not all shells are BASH. Only BASH is BASH.

dash is designed as a minimal shell for startup scripts, which intentionally lacks nearly all the features which make a shell nice to program in.
# 10  
Old 10-05-2011
Quote:
Originally Posted by Corona688
May I suggest you use anything other than the dash shell? maybe bash or ksh -- even busybox ash is better.

I also don't understand why you put BASH in the title when you don't have it. Not all shells are BASH. Only BASH is BASH.

dash is designed as a minimal shell for startup scripts, which intentionally lacks nearly all the features which make a shell nice to program in.
I don't think anyone in this thread has mentioned that they're using the dash shell. dash was only mentioned as the character, -, which the OP is using to mask the actual characters in the word. Although I too was confused by the proximity of "dash" to "BASH" in the title.

Also, gary_w isn't the OP.

Regards,
Alister
# 11  
Old 10-05-2011
Quote:
Originally Posted by alister
I don't think anyone in this thread has mentioned that they're using the dash shell.
:shrug: I have no idea why my original code didn't work for him, then.
# 12  
Old 10-08-2011
It worked fine.

Thanks for the help. alister...I was not able to use SED due to a trainer's request. I am actually training to do Developing with .Net/C##. But, our trainer wanted us to learn more about Unix and SQL prior to starting developing.

To further clarify, I was only using the Bash Shell with UNIX. The hangman problem required to replace a "dash" with the characters of a word.

Everything worked out great so thanks again to everyone for their input and assistance.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Replace \n char in Data

File is pipe delimited with 17 fields. We may get \n char (1 or more \n in one field or multi fileds) in data in any field. Need to replace \n in data with space and not the Ture \n that is line separator. I tried below awk command it did not work as expected. awk '(NR-1)%2{$1=$1}1' RS=\|... (9 Replies)
Discussion started by: rajeshkumare
9 Replies

2. UNIX for Beginners Questions & Answers

Views How to replace a CRLF char from a variable length file in the middle of a string in UNIX?

My sample file is variable length, with out any field delimiters. It has min of 18 chars length and the 'CRLF' is potentially between 12-14 chars. How do I replace this with a space? I still want to keep end of record, but just want to remove these new lines chars in the middle of the data. ... (7 Replies)
Discussion started by: chandrath
7 Replies

3. Shell Programming and Scripting

Using sed command replace date variable in unix

I need to use a shell script, using sed command how to replace date variable value in following format. 04/18/2012 11:38:55 Because the sed is treating the '/' as a parameter instead of the value of a variable, and hence there is the message as sed: command garbled: s/insert/04/18/2012... (9 Replies)
Discussion started by: jannusuresh
9 Replies

4. UNIX for Dummies Questions & Answers

Bash: using SED, trying to replace some characters except first or last line

Hi, I require to replace 2 items: 1. replace start of all lines in a file with ' except the first line 2. replace end of all lines in a file with '||chr( except last line I am able to do the entire file using sed -e s/^/\'/g -e s/$/\'\|\|chr\(/g "$file" > newfile.txt but am not yet... (3 Replies)
Discussion started by: Chella15
3 Replies

5. Shell Programming and Scripting

Bash: using SED, trying to replace some characters except first or last line

Hi, I require to replace 2 items: 1. replace start of all lines in a file with ' except the first line 2. replace end of all lines in a file with '||chr( except last line I am able to do the entire file using sed -e s/^/\'/g -e s/$/\'\|\|chr\(/g "$file" > newfile.txt but am not yet able... (0 Replies)
Discussion started by: Chella15
0 Replies

6. Shell Programming and Scripting

Replace last row of a column in bash/awk/sed

Hi, I've got a file with 3 columns which ends like this: ... 1234 345 1400 5287 733 1400 8472 874 1400 9317 726 1400 I want to replace the last row of the last column with the value 0. So my new file will end: ... 1234 345 1400 5287 733 1400 8472 874 1400 9317 726 ... (5 Replies)
Discussion started by: jhunter87
5 Replies

7. Shell Programming and Scripting

Bash sed search and replace question

I have several files that I need to modify using sed. I know how to do that, but now a new requirement has come up. Now, I need to make changes to all lines that don't start with certain strings. For example, I need to change all lines except for lines that start with "a", "hello there",... (3 Replies)
Discussion started by: RickS
3 Replies

8. Shell Programming and Scripting

SED: Place char at starting and replace selected line

Hello Experts, I am working on a small file editing script. Since all experts here are very generous to give me the complete code, I would take up the problem in steps so that I ensure my opportunity to learn. AIM: The script has some commented and some uncommented lines. I need to : ... (2 Replies)
Discussion started by: hkansal
2 Replies

9. UNIX for Dummies Questions & Answers

Unix script, sed search and replace?

Hi, I am trying to write a shell script designed to take input line by line by line from a file with a word on each line for editing with sed. Example file: 1.ejverything 2.bllown 3.maikling 4.manegement 5.existjing 6.systems My design currently takes input from the user, and... (2 Replies)
Discussion started by: mkfitzwilliams
2 Replies

10. Shell Programming and Scripting

How to replace any char with newline char.

Hi, How to replace any character in a file with a newline character using sed .. Ex: To replace ',' with newline Input: abcd,efgh,ijkl,mnop Output: abcd efgh ijkl mnop Thnx in advance. Regards, Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies
Login or Register to Ask a Question