03-15-2010
OK, with your help I go this:
line1=`sed -ne 5p ./Buttons | cut -d '*' -f2 | cut -d ';' -f1`
What I need now, is to replace the '5' by a variable ($couter2)... I don't know how to do this, have problems with the format... Just inserting $counter2 doesn't work... How do I have to do this???
./Buttons is the file where I get the lines from
line1 is the variable where is store the whole output to use later
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all,
I'm quite new to unix and hope that someone can help me on this.
I'm using csh.
Below is what i intend to do.
1. I stored some data in a file.
2. I intend to read the file line by line and store each line of data into a variable, so that i can used it later.
Anyone have any... (4 Replies)
Discussion started by: seijihiko
4 Replies
2. Shell Programming and Scripting
i have to store the files in a folder and assign a variable to the the files. (0 Replies)
Discussion started by: dineshr85
0 Replies
3. Shell Programming and Scripting
Example output:
/tmp/generatelines.sh
line1
line2
line3
line4
I want each output line assigned to its own variable, ie:
"line1" --> $a
"line2" --> $b
"line3" --> $c
"line4" --> $d
Is this possible without writing to a temporary file?
Thanks (4 Replies)
Discussion started by: ksheller
4 Replies
4. Shell Programming and Scripting
Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it.
The text file is in this form
text or numbers in first line
text or numbers in second line
.
.
.
Firsname... (6 Replies)
Discussion started by: amuthiga
6 Replies
5. Shell Programming and Scripting
i need to cut the string in a textfile but each line has a specific way of cutting it (different lengths)
i have a for loop that gets the string line per line, then each line has to be compared:
for x in `cat tmp2.txt`; do
if; then
echo 'BAC'
elif
... (6 Replies)
Discussion started by: izuma
6 Replies
6. Shell Programming and Scripting
Hi, I'm starting a little project with a shell script but I'm don't know how to do it. Maybe someone can help me.
I have un text file like this :
I'd like to do a script who will extract from my file from @ADDLINE1@ to @ADDLINE4@ only and I have no idea how to do this.
Any idea ?
... (7 Replies)
Discussion started by: Poulki
7 Replies
7. Shell Programming and Scripting
Hello, I am quite new in shell scripting and I would like to write a little scritp to run a program on some parameters files.
all my parameters files are in the same directory, so pick them up with
ls *.para >>dirafter that I have a dir file like that:
param1.para
param2.para
etc...
I... (2 Replies)
Discussion started by: shadok
2 Replies
8. Shell Programming and Scripting
My first post, so don't kill me :)
Say i open some textfile with some example like this.
on the table are handy, bread and wine
Now i know exactly what is in and i want to separate and sorted it in terminal to an existing file with another 2 existing lines in like this:
table
plane ... (3 Replies)
Discussion started by: schwatter
3 Replies
9. Shell Programming and Scripting
The bash below loops through a specific directory dir and finds and writes the oldest folder to a variable called $filename.
#!/bin/bash
# oldest folder stored as variable for analysis, version log created, and quality indicators matched to run
dir=/home/cmccabe/Desktop/NGS/test
find... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. Shell Programming and Scripting
Hi,
I am new to unix/linux scripting.
I have a text file, listlib.txt where the content:
lib1_23
lib34_a
ab_li_lab
I need to generate a file (.log) of each cell. I am planning to create a (.csh) script that will have for loop with variable taken from listlib.txt. As for now, i have no... (4 Replies)
Discussion started by: mmaz
4 Replies
cut(1) General Commands Manual cut(1)
Name
cut - cut out selected fields of each line of a file
Syntax
cut -clist [file1 file2...]
cut -flist [-dchar] [-s] [file1 file2...]
Description
Use the command to cut out columns from a table or fields from each line of a file. 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 delim-
iter character like tab (-f option). The command can be used as a filter. If no files are given, the standard input is used.
Use to make horizontal ``cuts'' (by context) through a file, or to put files together in columns. To reorder columns in a table, use and
Options
list Specifies ranges that must be a comma-separated list of integer field numbers in increasing order. With optional - indicates
ranges as in the -o option of nroff/troff for page ranges; for example, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short
for third through last field).
-clist Specifies character positions to be cut out. For example, -c1-72 would pass the first 72 characters of each line.
-flist Specifies the fields to be cut out. For example, -f1,7 copies the first and seventh field only. Lines with no field delim-
iters are passed through intact (useful for table subheadings), unless -s is specified.
-dchar Uses the specified character as the field delimiter. Default is tab. Space or other characters with special meaning to the
shell must be quoted. The -d option is used only in combination with the -f option, according to XPG3 and SVID2/SVID3.
-s Suppresses lines with no delimiter characters. Unless specified, lines with no delimiters are passed through untouched.
Either the -c or -f option must be specified.
Examples
Mapping of user IDs to names:
cut -d: -f1,5 /etc/passwd
To set name to the current login name for the csh shell:
set name=`who am i | cut -f1 -d" "`
To set name to the current login name for the sh, sh5, and ksh shells:
name=`who am i | cut -f1 -d" "`
Diagnostics
"line too long" A line can have no more than 511 characters or fields.
"bad list for c/f option"
Missing -c or -f option or incorrectly specified list. No error occurs if a line has fewer fields than the list calls
for.
"no fields" The list is empty.
See Also
grep(1), paste(1)
cut(1)