Sponsored Content
Homework and Emergencies Homework & Coursework Questions Issue with tr, removing [:alnum:] Post 302510299 by alindner on Saturday 2nd of April 2011 10:44:15 PM
Old 04-02-2011
Issue with tr, removing [:alnum:]

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
Code:
1. The problem statement, all variables and given/known data:
 
  1. You should also know how to find files based on their characteristics.
    1. Use stat to list the meta data for the file with inode number 2793324. Your command should suppress error messages. Hint: command substitution will make this easier!
    alindner@cs215:~$ find / -inum 2793324 -exec stat {} \; 2> /dev/null File: `/usr/lib/locale/bn_IN/LC_NAME' Size: 130 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 2793324 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2011-04-02 19:37:31.000000000 -0400 Modify: 2010-10-28 17:51:33.000000000 -0400 Change: 2011-01-16 18:08:54.000000000 -0500
    1. How many bytes would be in this file if all the alphas (a-z and A-Z) and all the numerics (0-9) where removed from it?
2. Relevant commands, code, scripts, algorithms: See 1 & 2 3. The attempts at a solution (include all code and scripts): So i am trying to remove the Alpha and Numeric characters, so i am using tr to do this, but it keep dumping characters on my screen? when i try to do this. Is this because when i less it it tells me its a binary file? tr -d "[:alnum:]" < LC_NAME4 Also wasnt sure if it was an issue with permissions as well so i made copies of the file to work on and changed permissions (chmod 7777 LC_NAME4) less LC_NAME4 ^]^Q^C ^G^@^@^@$^@^@^@/^@^@^@0^@^@^@=^@^@^@S^@^@^@f^@^@^@|^@^@^@%p%t%f%t%g^@^@শ�<8D>র�<80>^@শ�<8D>র�<80>মত�<80>^@�<95>�<81>মার�<80>^@শ�<8D>র�<80>মত�<80>^@UTF-8^@ LC_NAME4 lines 1-1/1 (END) Is there something im doing worn with tr? 4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course): KeeneState, KSC, Keene, NH, USA, Charlie W., CS215-01 Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it). ---------- Post updated at 10:44 PM ---------- Previous update was at 09:04 PM ---------- Looking tr it looks more like it for replacing? So would i be able use sed with the d option?

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing files

I have AIX 5.1 I was wondering how to remove a file name with a space in it Say {tb lsv.csv} ? When I use the {rm} command if you have a space it thinks it is a new file. So it looks for {tb} and {lsv.csv} instead of the name as a whole. Thanks in advance Dave By the way guys and gals the... (5 Replies)
Discussion started by: rocker40
5 Replies

2. Shell Programming and Scripting

Unix Arithmatic operation issue , datatype issue

Hi, I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ). Eg: 0000001 0000220 0001235 0000022 0000023 ........... ......... ........ Like this i am having around 1500000 records. After adding... (23 Replies)
Discussion started by: thambi
23 Replies

3. UNIX for Advanced & Expert Users

Issue with Removing Carriage Return (^M) in delimited file

Hi - I tried to remove ^M in a delimited file using "tr -d "\r" and "sed 's/^M//g'", but it does not work quite well. While the ^M is removed, the format of the record is still cut in half, like a,b, c c,d,e The delimited file is generated using sh script by outputing a SQL query result to... (7 Replies)
Discussion started by: sirahc
7 Replies

4. Shell Programming and Scripting

Vi - removing last word

Hi All, I want to remove last word from a line using Vi. Do we have any vi command for that. line : ss dd ff gg i have to run some vi command which can delete gg from the line Thanks, Ravi Sadani (4 Replies)
Discussion started by: ravi.sadani19
4 Replies

5. UNIX for Dummies Questions & Answers

ISSUE and ISSUE.NET files

In LINUX(CentOS, RedHat) is there a way to have the banner statement appear before the logon instead of after the logon? In UNIX and Windows the banner appears before a person actually logs on, what I'm seeing in LINUX is that it appears after the login(ftp, telnet, SSH). Thanks (0 Replies)
Discussion started by: ejjones
0 Replies

6. Shell Programming and Scripting

Removing whitespace issue

Hi, I have a file with rows like below delimited with pipe (|) I want to remove all the leading and trailing white space from each and every fields keeping the delimiter intact. I have tired this sed 's/*//g;s/*$//g' but the result is incorrect it is removing a whitespace from... (6 Replies)
Discussion started by: COD4
6 Replies

7. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

8. Shell Programming and Scripting

Removing Numbers

Hi, Below is a scattered representation of numbers . 1 2 11 22 11 22 1 2 1 2 11 22 1 2 11 22 I need to display only the following sequence "" and delete of the remainder from the output. The output should look like (2 Replies)
Discussion started by: Ananth12
2 Replies

9. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

10. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies
TRUNCATE(1)							   User Commands						       TRUNCATE(1)

NAME
truncate - shrink or extend the size of a file to the specified size SYNOPSIS
truncate OPTION... FILE... DESCRIPTION
Shrink or extend the size of each FILE to the specified size A FILE argument that does not exist is created. If a FILE is larger than the specified size, the extra data is lost. If a FILE is shorter, it is extended and the extended part (hole) reads as zero bytes. Mandatory arguments to long options are mandatory for short options too. -c, --no-create do not create any files -o, --io-blocks treat SIZE as number of IO blocks instead of bytes -r, --reference=RFILE base size on RFILE -s, --size=SIZE set or adjust the file size by SIZE bytes --help display this help and exit --version output version information and exit The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (pow- ers of 1000). SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of. AUTHOR
Written by Padraig Brady. REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report truncate translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
dd(1), truncate(2), ftruncate(2) Full documentation at: <http://www.gnu.org/software/coreutils/truncate> or available locally via: info '(coreutils) truncate invocation' GNU coreutils 8.28 January 2018 TRUNCATE(1)
All times are GMT -4. The time now is 07:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy