How do you delete characters in a shell script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do you delete characters in a shell script?
# 1  
Old 03-30-2010
How do you delete characters in a shell script?

I have printed a character on the screen using a shell script. I want to move that character one space to the left. I have tried moving the cursor to the top left corner of the screen and printing a backspace, like this:

Code:
tput cup 1 1;
printf "\b";

The backspace supposedly deletes the character under the cursor. But it won't do anything for me.

Is there any other way to do this?

Last edited by Ultrix; 03-30-2010 at 10:59 AM..
# 2  
Old 03-30-2010
Code:
tput cup 0 0

Should this not be?

Code:
tput cup 0 1

# 3  
Old 03-30-2010
Yeah, I know. That doesn't really help, though.
# 4  
Old 03-30-2010
Rethink.
Move the cursor back with \b , output a space character, move the cursor back with \b .

Code:
printf "line1"
printf "\b \b"
read junk


Last edited by methyl; 03-30-2010 at 12:40 PM..
# 5  
Old 03-30-2010
Quote:
Originally Posted by Ultrix
The backspace supposedly deletes the character under the cursor. But it won't do anything for me.
Backspace is not deleting any character, it just moves the cursor one position to the left. To erase a character, overwrite it with a space.
# 6  
Old 03-30-2010
If you use same tput more than once with some constant argument(s) then do tput once and save output.
After that use variable.

Code:
lear
cat <<EOF
=========================================================
Screen test


EOF
loc0_0=$(tput cup 0 0)
bold=$(tput  smso)
boldoff=$(tput rmso)
save_loc=$(tput sc)
ret_loc=$(tput rc)

# after this init, use variable
echo "${bold}BoldText${boldoff} and not so bold"
echo -e "(Look line 1) Ask here:${save_loc}${loc0_0}LOCATION 0,0 IS HERE ***************${ret_loc}\c"
read answer
echo "${save_loc}${loc0_0}Your answer:$answer   ${ret_loc}"
echo

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[Solved] Removing control-m characters from shell script

Hi All, I need to remove control m character from a file. Steps which i am doing in shell script are: 1) We are comparing the header of the file to the database table header Here the file header has control-m characters. How do i remove it. Please help. Below are the steps i am using,... (12 Replies)
Discussion started by: abhi_123
12 Replies

2. Shell Programming and Scripting

Want to remove the last characters from each row of csv using shell script

Hi, I've a csv file seperated by '|' from which I'm trying to remove the excess '|' characters more than the existing fields. My CSV looks like as below. HRLOAD|Service|AddChange|EN PERSONID|STATUS|LASTNAME|FIRSTNAME|ITDCLIENTUSERID|ADDRESSLINE1 10000001|ACTIVE|Testazar1|Testore1|20041|||... (24 Replies)
Discussion started by: rajak.net
24 Replies

3. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

4. Shell Programming and Scripting

How to type ISO_8859_1 characters in shell script?

Hello All, I want to type some special characters to check in my shell script as string. Could you please help me how do I type in my shell script. For example "LA CORUĆA". Here the last but 1 character is related to ISO_8859_1 related. But don't know how do I type in shell script programming.... (3 Replies)
Discussion started by: nvkuriseti
3 Replies

5. UNIX for Dummies Questions & Answers

shell script to find noof characters in a file name

hiiii shell script to find noof characters in a file name, when you run ls -l (using awk) I tried with this ls -l > temp awk -F"," '{print $1 " " expr length $9}' temp but it give some other value instead of file name length (error value like , 563,54,55,56....).How to prnint the... (10 Replies)
Discussion started by: krishnampkkm
10 Replies

6. Shell Programming and Scripting

How to call last 14 characters with grep/sed in shell script.

Hi. This is my first post on the forums. I am trying to write a script that will parse a folder of files "oneverylongfilenamexyz.pdf" and create a .dat file named "oneverylongfilenamexyz.dat" with the first line of each .dat file saying variable="xyz" where xyz is the last 14 characters of $i... (4 Replies)
Discussion started by: attonbitusira
4 Replies

7. Shell Programming and Scripting

writing shell script to find line of invalid characters

Hi, I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated. (3 Replies)
Discussion started by: beginner82
3 Replies

8. UNIX for Dummies Questions & Answers

Need help to escape special characters in Korn shell script

Hi, I would like to display the following message from my shell (Korn) script Copy "old_file.txt" to "new_file.txt" My code looks as follows print "Copy "old_file.txt" to "new_file.txt"" However, when I execute the script, I get the following output Copy old_file.txt to... (6 Replies)
Discussion started by: rogers42
6 Replies

9. Shell Programming and Scripting

Bold characters in a file using Shell script

Hi, When I am running below mentioned script then the characters become bold but after opening the same file in Windows, Instead of getting bold characters i am getting some garbage value for \033Kunal Dixit Output in Windows (after ftp the file): but in windows , i am getting My name is... (0 Replies)
Discussion started by: kunal_dixit
0 Replies

10. Shell Programming and Scripting

help removing characters for output file in shell script

hi i'm new to shell scripts and have a small problem i am running a batch converter that returns all flash .flv files in a directory and create a png image from each one the problem i have is the $1 variable , its ok on the first call but on the secound call $1.png , i have extra... (1 Reply)
Discussion started by: wingchun22
1 Replies
Login or Register to Ask a Question