displaying mutliple fields on command line


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers displaying mutliple fields on command line
# 1  
Old 11-01-2007
displaying mutliple fields on command line

This is probably the dumbest question you guys can get, but I'm trying, as a complete noob, to display the unix calendar for all the months without Saturday and Sunday showing. How can I remove those fields without having to type all the fields in individually such as:

cal -y | awk '{print $2, $3, $4....etc.

I would like to just list 2 trough 6, then 10 through 14, 18 through 22 like that.

Any ideas?

Thanks,

Trellot
# 2  
Old 11-02-2007
this one destroys all the formatting:
Code:
cal -y | sed 's/  */ /g' | cut -d " " -f 2-6,9-13,16-20

sed 's/ */ /g'
convert multiple spaces into a single space

cut -d " " -f 2-6,9-13,16-20
show columns 2 to 6, 9 to 13, and 16 to 20
# 3  
Old 11-02-2007
using awk, but even this doesn't preserve all the formatting:
Code:
cal -y | awk '{printf "%2s %2s %2s %2s %2s %2s %2s %2s %2s %2s %2s %2s %2s %2s %2s \n",$2, $3, $4, $5, $6, $9, $10, $11, $12, $13, $16, $17, $18, $19, $20}'

# 4  
Old 11-02-2007
Code:
cal -y|cut -c4-17,21-23,27-40,44-46,50-63

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Displaying every other line in an array.

Hi, I have an array, that works well. But, I want to have it display every other line. Like so, 1, 3, 5, 7, etc, etc. Here is the relevant code: I'm sorry for the pastebin link. For some reason, I can't get the code to format properly with the code tags. code tags work fine... everyone... (4 Replies)
Discussion started by: ignatius
4 Replies

2. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies

3. Shell Programming and Scripting

Not able to sort two fields and printf not displaying the correct values

Not able to sorting two fileds resolved printf issue 01-1000/9|JAN 01-0000/6|MAN 01-1010/2|JAN 01-1010/2|JAN 01-1010/2|JAN 01-1000/9|JAN 01-1000/9|JAN 01-1000/9|SAA 01-1000/9|SAA 01-0000/6|SAN 01-0000/6|SAN 1.sort -t'|' -k1,1n -k2,2 file (3 Replies)
Discussion started by: kalia4u
3 Replies

4. Shell Programming and Scripting

Comparing fields of two files and displaying results

Hello , I am trying to compare two files i.e one master file and the other exclusion file. If the second field of masterfile is oracle8 then I need to compare the 3rd field of master file with the 1st field of all the rows of exclusion file else I need to compare 2nd field from master file with... (2 Replies)
Discussion started by: rahul2662
2 Replies

5. Red Hat

Displaying command return in one line

Hello all I have a query (SQL) that returns a rather long field from an Oracle database. The field in question is defined on 400 characters but all these 400 cannot be displayed by the echo command. Thus when I launch the following command: echo "SELECT FIELD01 FROM TABLE_NAME;" | sqlplus -s... (9 Replies)
Discussion started by: S. BASU
9 Replies

6. Shell Programming and Scripting

Print mutliple patterns in a line using sed

Hi, I am trying to print multiple patterns in a line using sed. But it is printing only the last occurance of a pattern. If the line is the the output should be Lookup Procedure|Stored proc But the output I am getting is Stored proc The code I am using is echo... (9 Replies)
Discussion started by: kedar_laveti
9 Replies

7. Shell Programming and Scripting

How to set mutliple words variable from command line

I'm writing a script (C shell) to search for a pattern in file. For example scriptname pattern file1 file2 filenN I use for loop to loop through arguments argv, and it does the job if all arguments are supplied. However if only one argument is supplied (in that case pattern ) it should ask to... (5 Replies)
Discussion started by: patryk44
5 Replies

8. Shell Programming and Scripting

displaying the path in the command line

Hi all, Does anyone know how to ammend the .cshrc file in $HOME for your session to display the path as part of the command line? So that I dont need to keep on typing pwd to see where I am? thanks Ocelot (2 Replies)
Discussion started by: ocelot
2 Replies

9. Programming

Displaying fields in wtmp file?

Anyone have any idea on how to display the fields for each record stored in the wtmp file using C? Am I correct in thinking that the info stored in wtmp is in binary and that utmpx will be of some help? Being a beginner, I can come up with bits and pieces of what I might need in order to do the... (1 Reply)
Discussion started by: eclapton1
1 Replies

10. UNIX for Dummies Questions & Answers

displaying the first line?

how do i display just the first line of a file with the cat command or any command for that matter (4 Replies)
Discussion started by: imuuk
4 Replies
Login or Register to Ask a Question