No doubt these questions have been answered many times, but I struggled to find them - sorry. 2 questions:
1. I wish to read in a file one line at a time and do 'stuff' with it, such as:
If 'line' has 6 columns and I want only $4, how do I insert only that column into the web address rather the whole line?
2. If I have 2 files A & B, both having multiple columns, how do I take these 2 files and create a new file with columns in the format A2, B1, A3. Where A2 denotes the 2nd column from file A etc.
Thank you for such a quick reply - I should maybe have made my question a bit clearer.
1. This is useful thank-you!
However I was looking to access directly the elements of each line though, so that if for example $4 didn't return what I was after, then I could try $5. Then, depending on what column was finally used I would then print out either $1, $2 or $3 from that same line... plus some more stuff.
I realise now that I could just take each line and put it into a temporary new file and access its elements that way - it would just have been nicer if i was able to use some variable like $(line$2).
Hi All,
i want to write a shell script read below file line by line and want to exclude the lines which contains empty value for MOUNTPOINT field.
i am using centos 7 Operating system.
want to read below file.
# cat /tmp/d5
NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root"... (4 Replies)
:D:D:D
These are list of command i typed on opensuse terminal and evolve lots of doubt around ,that i can't answer.
COMMAND 1 linux-xavv:/ # cd
COMMAND 2 linux-xavv:~ #
Does above command 1 and command two with red labelled sign make different meaning or same .
1
linux-xavv:/... (1 Reply)
Hello,
I am creating a new disk using the following command:
dd if=/dev/zero of=/export/home/ramdisk/0 bs=512 count=4096k
after creating the disk, i tool a ufsdump of a solaris 10 filesytem (disk size 512MB)
ufsdump -cvf /export/home/ufsdump/sol_orig /and then restored the dump files onto... (10 Replies)
Hi,
I want to read a live log file line by line and considering those line which start from time stamp;
Below code I am using, which read line but throws an exception when comparing line that does not contain error code
tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Hi,
i have a scenario were i should compare a few fields from each line then increment a variable based on that.
Example file
989878|8999|Y|0|Y|N|V
989878|8999|Y|0|N|N|V
989878|8999|Y|2344|Y|N|V
i have 3 conditions to check and increment a variable on every line
condition 1 if ( $3... (4 Replies)
I need some help. I would like to read in a text file.
Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01.
Is this possible? any help is appreciated. (2 Replies)
So, I want to read line-by-line a text file with unknown number of files....
So:
a=1
b=1
while ; do
b=`sed -n '$ap' test`
a=`expr $a + 1`
$here do something with b etc
done
the problem is that sed does not seem to recognise the $a, even when trying
sed -n ' $a p'
So, I cannot read... (3 Replies)
*This is not homework I am new to UNIX and want to try this Monitoring a file demo*
*If this is the wrong forum please move it - im new to the forums*
$1 = the file to be monitored
$2 = the time for the file to sleep
If the file gets changed (using -nt) it will send my username mail saying... (2 Replies)
I have a csv file with 3 columns. Column 1 is a date "mm/dd/yyyy", column 2 is a dollar amount (e.g. "100.00") & column 3 in a description of where the transaction took place (e.g. "CHECK CRD PURCHASE 10/07 ACME INC USA")
so...
"10/01/2009","100.00", "CHECK CRD PURCHASE 10/07 ACME INC USA"
I... (1 Reply)