10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hey,
can someone explain me this script?
i=0
while read WORT
do
echo $WORT|grep a>/dev/null || echo$WORT|grep B>dev/null || let i=$i+1
done
echo $i
The first lane initializie the variable i with the value of 0.
The loop line has 3 different options because of ||. The only option I... (10 Replies)
Discussion started by: newuser21
10 Replies
2. Shell Programming and Scripting
Hi
My friend wrote this particular script and won't tell me what it does, and when I run it I don't understand it.
What does the entire script do with specifics please.
Thanks
Bob
#!/bin/bash
current=0
while ; do
if ; then
echo ${current}
current=$((${current}+1))
fi
done (1 Reply)
Discussion started by: shadowknight777
1 Replies
3. Shell Programming and Scripting
To merge mutiple *.tab files as:
file1.tab
rs1 A A
rs2 A A
rs3 C C
rs4 C Cfile2.ind
rs1 T T
rs2 T T
rs3 G G
rs4 G Gand file3.tab
rs1 B B
rs2 B B
rs3 L L
rs4 L LOutput:
file1.tab file2.tab file3.tab
AA TT BB
AA TT BB
CC GG LL
CC GG ... (4 Replies)
Discussion started by: yifangt
4 Replies
4. Solaris
Hello Guys,
can someone help explain the script below for me? I will really appreciate it.
vi db_script
#!/bin/sh
echo .cron job run on.`date`> cronjob.txt
df -h >> cronjob.txt
echo welcome to home (2 Replies)
Discussion started by: cjashu
2 Replies
5. Shell Programming and Scripting
The following script will create a directory in a directory and will go on as many times as the number you will give in.
I am trying to find out how it works ... can someone please help me with that?
#!/bin/sh
#create a variable and set it to 1
n=1
#start a loop as... (3 Replies)
Discussion started by: I-1
3 Replies
6. Shell Programming and Scripting
#script
fileused=test.txt
hostname=test.dis.com
ftp $hostname <<-! > $fileused.err 2>&1
put file.txt /usr/text.txt
bye
!
kindly the above script the one marked as Bold and underlined as the above i am declaring the new variable as filename ,But when i used i had used as $fileused.err... (1 Reply)
Discussion started by: rajar_r
1 Replies
7. Shell Programming and Scripting
Hello,
I have seen this script on this site. I understand most of it. However I am a bit stuck on the part in red. It appears to be expanding
for file in *.zip
do
zipdir=${file%.*}
mkdir $zipdir || echo "unable to create $zipdir"
cp $file $zipdir || echo "unable to copy $file"... (3 Replies)
Discussion started by: jaysunn
3 Replies
8. Shell Programming and Scripting
Guys,
was wondering what the meaning of the below bit is ?
awk -F ' ' '{print $1 " " $2 ;}' $TEMPFILE | (rm -f $TEMPFILE; sed 's/$/ '"$box"'/g' > $TEMPFILE)
Can anyone explain this in detail? what is the significance of rm -f $TEMPFILE here? What all IO/buffering happens here ?How the... (0 Replies)
Discussion started by: hashin_p
0 Replies
9. Shell Programming and Scripting
I have a script that has defined a log file like this.
The name of the script is verify.sh
Inside the script there is some thing like this.
LOG=/usr/verify
TDATE=`date "+%m%d%y"$$`
LOGFILE=$LOG.$TDATE.
and inside the script it has been written as
echo "This is to verify" | tee -a... (2 Replies)
Discussion started by: sendhilmani
2 Replies
10. Shell Programming and Scripting
I have the following script
awk '$1 ~ /^*+/ {
s += $NF;
m++
}
END {
print NR, m, s
}
and I use it to get results from the following file
A4792 4
COMP9021 5
K9 7
ABC 8
924 1
R2D2 3 (8 Replies)
Discussion started by: sickboy
8 Replies
cut(1) User Commands cut(1)
NAME
cut - cut out selected fields of each line of a file
SYNOPSIS
cut -b list [-n] [file]...
cut -c list [file]...
cut -f list [-d delim] [-s] [file]...
DESCRIPTION
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection
of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the
length can vary from line to line and be marked with a field delimiter character like TAB (-f option). cut can be used as a filter.
Either the -b, -c, or -f option must be specified.
Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally).
To reorder columns in a table, use cut and paste.
OPTIONS
The following options are supported:
list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indi-
cate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)).
-b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b and
-n are used together, list is adjusted so that no multi-byte character is split.
-c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line).
-d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special
meaning to the shell must be quoted. delim can be a multi-byte character.
-f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for
instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (useful
for table subheadings), unless -s is specified.
-n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split.
-s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed
through untouched.
OPERANDS
The following operands are supported:
file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used.
USAGE
See largefile(5) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2^31 bytes).
EXAMPLES
Example 1 Mapping user IDs
A mapping of user IDs to names follows:
example% cut -d: -f1,5 /etc/passwd
Example 2 Setting current login name
To set name to current login name:
example$ name=`who am i | cut -f1 -d' '`
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MES-
SAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 All input files were output successfully.
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|CSI |Enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO
grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5)
DIAGNOSTICS
cut: -n may only be used with -b
cut: -d may only be used with -f
cut: -s may only be used with -f
cut: cannot open <file>
Either file cannot be read or does not exist. If multiple files are present, processing continues.
cut: no delimiter specified
Missing delim on -d option.
cut: invalid delimiter
cut: no list specified
Missing list on -b, -c, or -f option.
cut: invalid range specifier
cut: too many ranges specified
cut: range must be increasing
cut: invalid character in range
cut: internal error processing input
cut: invalid multibyte character
cut: unable to allocate enough memory
SunOS 5.11 29 Apr 1999 cut(1)