Help needed in some unix commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in some unix commands
# 1  
Old 08-31-2010
Help needed in some unix commands

Hi,
Solutions may be in ksh or bash
1. i have some files like.
Code:
CAT_CO00102_20100816190955.Z   CAT_CO00102_20100816190955Q.Z  CAT_CO00202_20100825135947A.Z

to find out files ends with A.Z or Q.Z i use following in ksh.
Code:
 
CAT="CAT*[A|Q].Z"
ls $CAT
CAT_CO00102_20100816190955Q.Z  CAT_CO00202_20100825135947A.Z

i want to find out files which don't have A.Z or Q.Z in the end using ls command?

2. i define a function outside the nawk command which trims the leading and trailing spaces like
Code:
  function TrimSpace(x)
  {
    y=gsub(/^[ \t]+|[ \t]+$/,"",x)
    {
      return x
    }
  }

and i want to call this function in nawk commad like.
Code:
nawk '{print TrimSpace($1)}' file

Note: this function works fine if i define it within nawk.You may use your any dumy function for testing.
If it is possible to any outside function in nawk? and if yes,how to accomplish it

3. Sometimes while unziping some files i got an error and the further unziping stopped.might be other files are able to be unzip.i.e
Code:
 
gunzip a.Z b.Z c.Z 
gunzip: a.Z: unexpected end of file

it found an error on a.Z and stopped but b.Z and C.Z might be correct.
why this error comes and is there any possible way to skip the file with error and let the others start to unzip.

Advance thanks
# 2  
Old 08-31-2010
Question 1:

Code:
ls |grep -v "[A|Q].Z$"

# 3  
Old 08-31-2010
Quote:
Originally Posted by rdcwayx
Question 1:

Code:
ls |grep -v "[A|Q].Z$"

thanks for quick response but i also want to use pattern also in search like
ls|grep -v "^CAT*[A|Q].Z$"
# 4  
Old 08-31-2010
Quote:
Originally Posted by malikshahid85
thanks for quick response but i also want to use pattern also in search like
ls|grep -v "^CAT*[A|Q].Z$"
Code:
ls|grep -v "^CAT.*[A|Q].Z$"

# 5  
Old 08-31-2010
Quote:
Originally Posted by rdcwayx
Code:
ls|grep -v "^CAT.*[A|Q].Z$"

thanks but it also grep other files too like
Code:
CAT_CO00102_20100816190955.Z
abc.txt



---------- Post updated at 02:30 AM ---------- Previous update was at 01:51 AM ----------

plz urgent help needed
# 6  
Old 08-31-2010
I test the command again, and don't find any issue.

-v option will exclude any files start with CAT, and end with A.Z or Q.Z.

Code:
$ cat infile
CAT_CO00102_20100816190955.Z
CAT_CO00102_20100816190955A.Z
CAT_CO00102_20100816190955Q.Z
abc.txt

$ grep -v "^CAT.*[A|Q].Z$" infile
CAT_CO00102_20100816190955.Z
abc.txt

This User Gave Thanks to rdcwayx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help needed - UNIX command

The 'env' command prints out all of the environment variables and their values. Come up with a command that prints a list of environment variables whose names end with either 'NAME', 'DIR' or 'PATH'. What I've tried. $ env | grep '' Although it highlights the part of the variables... (8 Replies)
Discussion started by: edujs7
8 Replies

2. Shell Programming and Scripting

Linux Commands needed for replacing variable number of spaces with a single , in a txt file

Hi I want to read a text file and replace various number of spaces between each string in to a single "," or any other character .Please let me know the command to do so. My input file is a txt file which is the output of a SQL table extract so it contains so many spaces between each column of the... (2 Replies)
Discussion started by: Hari Prasanth
2 Replies

3. Homework & Coursework Questions

Unix Homework Help needed

1 Petras Pavardenis 1980 5 08 Linas Bajoriunas 1970 10 3 Saulius Matikaitis 1982 2 5 Mindaugas Stulgis 1990 7 6 Rimas Nasickis 1964 10 7 ... (1 Reply)
Discussion started by: vaidastf
1 Replies

4. Solaris

Help needed - trying to run commands in Guest LDoms from Control LDOM

Hi Folks, I am used to writing scripts to get info by running commands at local zones level from their respective global zone by using zlogin <localzone> "command>" while remaining at the global zone level. Can the same be done with Guest LDoms while remaining at the control LDOM level? ... (4 Replies)
Discussion started by: momin
4 Replies

5. Shell Programming and Scripting

Help needed in unix commands

i define a function outside the nawk command which trims the leading and trailing spaces like function TrimSpace(x) { y=gsub(/^+|+$/,"",x) { return x } } and i want to call this function in nawk commad like. nawk '{print TrimSpace($1)}' file Note:... (2 Replies)
Discussion started by: malikshahid85
2 Replies

6. UNIX for Dummies Questions & Answers

Running UNIX commands remotely in Windows box from Unix box – avoid entering password

I am able to run the UNIX commands in a Windows box from a UNIX box through "SSH" functionality. But whenever the SSH connection is established between UNIX and Windows, password for windows box is being asked. Is there a way to avoid asking password whenever the SSH connection is made? Can I... (1 Reply)
Discussion started by: D.kalpana
1 Replies

7. Shell Programming and Scripting

unix manual needed :)

hi guys... am new 2 dis unix world... am in need of a unix manual... cud sum1 pls post sum links 2 download it?>?>? :confused: Danks in advance... ;) ;) ;) (1 Reply)
Discussion started by: sundar_shankar
1 Replies

8. UNIX for Dummies Questions & Answers

Unix help needed !!

friends i wanted to now whehter there exists a book as a solution to the questions posted in exercies of the Design of Unix Operating system by Maurice J Bach !..its really urgent !! (1 Reply)
Discussion started by: darshaan
1 Replies

9. UNIX for Dummies Questions & Answers

Maingrame to UNIX sending UNIX commands

I want to know if there is a way to send unix commands thru FTP from a mainframe to kick off Autosys Jobs. I just need to send a command from the mainframe to UNIX and have UNIX execute that command. (2 Replies)
Discussion started by: skammer
2 Replies

10. UNIX for Dummies Questions & Answers

Unix help needed!

I have a few questions about Unix. Can you please help! 1.How do I create an alias that greps the password file for my username and returns my password file entry? Once I get the alias to work I want to be able to let a friend use it .So that he can use the alias to locate his password entry... (1 Reply)
Discussion started by: JJJ
1 Replies
Login or Register to Ask a Question