need clarification about tr -d command ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need clarification about tr -d command ?
# 1  
Old 03-18-2008
Data need clarification about tr -d command ?

Hi ,
I need your help to know the exact operation of this following code ..

cat file1 | ux2dos | tr -d ''>>file2

file1 contains only one line : "DTS-PO\SPECTRUM WO 56"
the data contains a META CHAR "\" .. look at the above line.
But , The file2 output contains : "DTS-POSPECTRUM WO 56^M"
The "\" does not appear in the file2.
The ux2dos appends ^M in the end of line.

My questions are :

1. what is the operation performed by tr -d '' ?
what is the usage of this arrow mark option ?
2. is the arrow option ignore the ALL Special meta char's? or the ux2dos ignore or delete the special META Char's?
3. is there any way to allow the meta char's would be appeared in the file2?

Note : Environment = IBM AIX 5.3
Shell = ksh
# 2  
Old 03-18-2008
tr -d " does not make any sense.

Are you sure it was not tr -d "\""?
# 3  
Old 03-18-2008
fpmurphy: his example has a literal control character which my browser displays as an empty box.

This smells of homework from the intro course. @vparunkumar: Read the book your lecturer gave you, it has the answers and that's why he gave it to you.

Send him o her our regards, you can say we awarded a "Useless Use of Cat Award" for this example.
era
# 4  
Old 03-18-2008
Hammer & Screwdriver

Agreed with era..Smilie

But to get you going , following is the one of the most common usgaes of tr -d..

Code:
ls -l /home/nua7 | tr -d " " | cut -d " " -f2

This would list all files in the given path, equally space out the fields with a space " ", which is further used as a demiliter in cut command.

Hope this helps..!

Last edited by Yogesh Sawant; 03-18-2008 at 09:30 AM.. Reason: added code tags
# 5  
Old 03-18-2008
Power To fpmuphy and era

In my previous post , some char was missing in tr command !!!

the actual script line looks like

cat file1 | ux2dos | tr -d '->' >>file2

i could not able to copy/paste the exact symbol.. this editor doesnt accept ... , but it is a perfect arrow symbol(->)

To era : :-)
This is not LAB exercise .....real time issue ...
I am working in IBM India..and i am new to AIX/UNIX . This is a bug , which i found .. But i could not understand the meaning of arrow symbol ..
could you help me ?
# 6  
Old 03-18-2008
tr -d removes any occurrence of the indicated character(s) from the input, and copies the rest. A very quick glance at the tr(1) manual page would have told you this.

Conventionally ux2dos replaces line feeds with carriage return+line feed but it's not a standard command, it could do other stuff like change slashes in file names to backslashes or what not if it's a specialized command. (Often unix2dos is a simple wrapper around a one-line tr or sed script, too.)

If you don't want to remove the mystery arrow character, take out the "tr". I assume it was put there for a reason, though.

Sorry for the sarcasm, and hope this helps.
era
# 7  
Old 03-18-2008
To era

Smilie I am a fresh engineering graduate , recently joined in IBM .. and new to this AIX/unix Smilie
Thanks for your valuable reply ..

Now i understood the tr -d command ..

is the problem due to ux2dos conversion ?
will ux2dos change/modify the input string which contains meta char ?

please give me some links , to read about ux2dos ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Clarification on Case command

Hi, I'm a newbie to shell programming and have just written a small program to transfer files. # job variables RunMode=$1 export DATETIME=`date +%Y%m%d%H%M%S` export STARTTIME=`date +%Y%m%d%H%M` export ShellDir=/rosetlt/scripts/ksh export LogDir=/rosetlt/scripts/log export... (2 Replies)
Discussion started by: narayanv
2 Replies

2. Shell Programming and Scripting

Net rpc command clarification

Hi, I am checking below command to see the status of windows service from unix but due to "!" sign it is not accepting password. Please suggest alternative what should i do resolve the issue. net rpc service status W32Time -I 10.1.1.1 -U "mydomain\admin%Passwod12!" One more thing... (1 Reply)
Discussion started by: learnbash
1 Replies

3. HP-UX

su command clarification

Hi, I want to use the "SU" command in script it is asking me to enter the password manually. pleas the say the syntax of su command in single line that includes username/password. :) (3 Replies)
Discussion started by: vigneshwaran007
3 Replies

4. UNIX for Advanced & Expert Users

Need clarification

We are facing problem while executin below script, cat $PIPE_FILE | imscp - "${LRX_FILE_LOC}" 2>&1 | tee "${LIST_DIR}/${IMSCP_OUT_FILE}" & sqlplus -s ${REPORTING_CONNECT} <<EOF whenever sqlerror exit 1 rollback spool ${PIPE_FILE} start ${LRX_EXEC_SQL} ${LRX_MDL_RUN_DATE} spool off exit... (4 Replies)
Discussion started by: samiks14
4 Replies

5. UNIX for Dummies Questions & Answers

Clarification on '1 days ago' in date command [Found answer, posted within]

I know the topic of getting yesterday's date has been covered ad nauseum, but I just want to be clear on something. I recently started using the command date --date='1 days ago' '+%m/%d/%y' to get yesterday's date and it's been working great. I just want to be certain that it is going to... (1 Reply)
Discussion started by: DeCoTwc
1 Replies

6. Shell Programming and Scripting

clarification Required in Write command

Hi All, can you please help me to get clarified about the 'write' command. I have a script that sends a content of a file msg.txt to other user 'User B' using 'write' command. Script: ------ ..... cat msg.txt | write "user B" ..... Issue: I face a issue here, this scripts sends... (3 Replies)
Discussion started by: little_wonder
3 Replies

7. Web Development

Clarification

:confused: Hi All, i am new to unix....so i am not sure whether i am asking the related question with our forum.. My question .....Can anyone explain me about the CGI script is it something related to Unix or Linux or some other language. Thanks in advance Sha (1 Reply)
Discussion started by: Shahul
1 Replies

8. Solaris

Sun Unix command clarification

I am reading a Sunsolve document covering moving /var and am confused by one step. What does this command do (in English): Move into the existing /var directory and transfer all the data to /newvar # cd /var # tar cvf - . | (cd /newvar; tar xfBp -) (4 Replies)
Discussion started by: FredSmith
4 Replies

9. Shell Programming and Scripting

nawk command clarification

Hi, I am using the following command. nawk '$1==p{$2=sprintf("%09d",$2+1)};1' p=$JOB_NUM q=$LEN $VALUE_TABLE > ./TEMP_TABLE As you can see the code above, I basically read a value from the table VALUE_TABLE and select a particular row based on searching the value JOB_NUM. Now Actually the... (2 Replies)
Discussion started by: Tux_Raju
2 Replies

10. UNIX for Dummies Questions & Answers

"find" command clarification

Hi everyone, I have a very simple question to ask : How can I locate the files created the last "n" days? (the find command has 3 options : -atime, -ctime, -mtime, but none of these returns the newlly created files ... am I wrong?) Thank you. (3 Replies)
Discussion started by: ck-18
3 Replies
Login or Register to Ask a Question